Skip to Content

Where can I see Facebook code?

Where can I see Facebook code?

Facebook is a massive social media platform with billions of users worldwide. As one of the biggest tech companies, much of Facebook’s codebase is proprietary and kept private for competitive reasons. However, Facebook does make portions of its code open source and available for the public to view.

Open Source at Facebook

While the core Facebook app is closed source, Facebook has open sourced many supporting projects and tools. This allows developers outside of Facebook to use and contribute to technologies that Facebook has created.

Some major open source projects from Facebook include:

  • React – A JavaScript library for building user interfaces
  • GraphQL – A query language for APIs
  • PyTorch – A Python machine learning library
  • RocketSpeed – A server architecture for speeding up web servers
  • HHVM – A virtual machine for running PHP code

Facebook maintains active GitHub organizations for its open source projects. As of October 2022, Facebook has over 900 public repositories on GitHub with over 160,000 combined stars.

Browsing Facebook’s GitHub

The best way to view Facebook’s open source code is to browse Facebook’s GitHub organizations:

From Facebook’s GitHub organizations, you can see all public repos from Facebook engineers. This includes code for popular projects like React Native, Immutable.js, and Jest.

You can browse the code, clone repos to your local machine, and submit issues or pull requests. However, keep in mind that contributing requires following each project’s specific contribution guidelines.

Notable Open Source Projects

Here are some of the most notable open source projects from Facebook:

React

React is a declarative JavaScript framework for building interactive user interfaces. React allows developers to build composable components that manage their own state.

Key React repositories include:

GraphQL

GraphQL is a query language for APIs that allows clients to specify exactly what data they need. It was created at Facebook as an alternative to REST APIs.

Key GraphQL repositories include:

PyTorch

PyTorch is an open source machine learning framework based on Python and Torch. It is used for computer vision, natural language processing, and other AI tasks.

Key PyTorch repositories include:

Other Notable Projects

Some other notable open source projects from Facebook include:

  • Buck – A fast build tool for Android and iOS apps
  • FBLearner Flow – A framework for deploying machine learning pipelines
  • FBInfer – A declarative DSL for ML models
  • TorchServe – A tool for serving PyTorch models
  • ThreatExchange – A platform to share threat data

Internal Facebook Code

While Facebook open sources many tools and technologies, the core Facebook app remains closed source and proprietary. This includes the backend code running Facebook’s mobile apps and web platform.

Some examples of internal Facebook code and systems include:

  • News Feed ranking algorithm
  • GraphQL API backend
  • Cache infrastructure
  • Anti-abuse and spam systems
  • Privacy controls

Keeping core code closed allows Facebook to add new features and fix bugs without public scrutiny. It also gives Facebook a competitive advantage to have private systems powering their platform.

Some portions of internal code have leaked publicly over the years. For example, leaked caches revealed ranking factors used by Facebook’s News Feed algorithms. However, Facebook actively works to prevent and remove leaks of proprietary code.

Viewing Facebook App Code

While you can’t access the private backend code, you can view frontend code running the Facebook website and mobile apps. Modern browsers come with developer tools that let you inspect JavaScript, CSS, and other assets loaded by a website.

To view frontend Facebook code:

  1. Open facebook.com in Chrome or another browser.
  2. Right click and select Inspect or Inspect Element.
  3. The Developer Tools panel will open. Here you can view:
    • The HTML source code
    • The CSS styles
    • The JavaScript files loaded
    • Network requests made
    • Storage (cookies, localStorage, etc.)
    • Console logs and errors
  4. Click on different page elements to see the associated code.
  5. Use the Network tab to see assets loaded on page load and when interacting.

This allows you to see how Facebook builds the UI and fetch data from their APIs. However, you won’t see any proprietary backend logic.

Finding Facebook Open Source Contributors

Facebook employs thousands of engineers around the world. Many of them contribute to open source projects in public ways:

  • GitHub profiles – Facebook engineers list their employer on GitHub. Search “facebook” to find them.
  • Commit histories – Look at commit logs on Facebook projects to find contributors.
  • Presentations/Talks – Facebook engineers sometimes discuss projects publicly at conferences.
  • Social media – Engineers will promote projects on Twitter, Facebook, etc.
  • LinkedIn – Search for engineers by employer.
  • Open source listings – Some engineers share their open source work on LinkedIn and personal sites.

By finding engineers involved in projects, you can often view their code samples and connect with them about contributing.

Learning from Facebook’s Code

Here are some ways Facebook’s open source code can help you as a developer:

  • Solve coding problems – Facebook projects provide examples of high-quality code for reference.
  • Learn new technologies – Follow React and GraphQL tutorials to add skills.
  • Improve performance – Apply Facebook techniques around caching, image loading, etc.
  • Increase security – Use secure defaults from Facebook’s framework configurations.
  • Prototype ideas – Quickly build a frontend MVP with React and GraphQL.
  • Contribute code – A good way to learn while giving back to the community.

Studying how experienced engineers solve problems can help improve your own coding skills. Facebook’s open source contributions also let you give back by submitting improvements of your own.

Conclusion

While most of Facebook’s codebase is private, they open source many valuable technologies and tools. Developers can browse Facebook code on GitHub, inspect webpages through browser dev tools, and learn from engineers’ public contributions.

Facebook’s open source projects provide real world examples to learn from and codebases that anyone can contribute to. Studying how Facebook engineers build software can provide insights that make you a better developer.