Free Online Code Formatter - Powered by Prettier

Format code online with Prettier: JavaScript, TypeScript, JSX, CSS, SCSS, Less, HTML, Markdown, YAML, JSON and GraphQL. Set width, tabs, quotes and semicolons.

  • No upload, 100% private
  • Instant, in your browser
  • 100% free, no signup
Loading tool…
Read the complete guideWhat Is Prettier? How Opinionated Code Formatting Works →

About the Code Formatter (Prettier) tool

Consistent formatting makes code easier to read and review, and it stops pointless whitespace changes from cluttering diffs. Prettier has become the standard formatter for web code, but it normally needs Node and a project setup. This online code formatter runs Prettier itself in your browser, with its official language plugins.

Choose JavaScript/JSX, TypeScript/TSX, JSON, CSS, SCSS, Less, HTML, Markdown, YAML or GraphQL and paste your code; it is reformatted as you type. HTML formatting also formats embedded <script> and <style> blocks, and Markdown formatting normalises lists, headings and tables. You can set the print width, indent with 2 or 4 spaces or tabs, and for JavaScript and TypeScript choose semicolons, single or double quotes and trailing commas.

Only the plugins for the selected language are loaded, and your code never leaves the page. If the code has a syntax error, Prettier's message is shown with its line and column so you can fix it.

How to use Code Formatter (Prettier)

  1. Choose the “Language” of your code.
  2. Paste code into the input, open a file, or click “Load sample”.
  3. Adjust “Print width”, “Indent”, and for JS/TS “Trailing commas”, “Semicolons” and “Single quotes”.
  4. Read the formatted code in the right-hand pane; syntax errors show their line and column.
  5. Copy the result or download it with the right file extension.

Features

Real Prettier

Uses prettier/standalone and the official plugins, so output matches your editor's Prettier.

Ten languages

JavaScript, TypeScript, JSON, CSS, SCSS, Less, HTML, Markdown, YAML and GraphQL.

Familiar options

printWidth, tabWidth, useTabs, semi, singleQuote and trailingComma.

Embedded code

Scripts and styles inside HTML, and code blocks in Markdown, are formatted too.

Loads only what is needed

Each language's parser downloads on demand to keep the page fast.

When to use it

  • Clean up a minified or badly indented snippet before debugging it.
  • Format code for a blog post, documentation page or Stack Overflow answer.
  • Normalise a YAML file such as a GitHub Actions workflow or Kubernetes manifest.
  • Tidy a Markdown README with consistent lists and tables.
  • Check how Prettier will format code before adding it to a project.

Frequently asked questions

Is this the same as Prettier in VS Code?

Yes, it is the same Prettier 3 formatter and plugins. Results match when you use the same options; project .prettierrc files are not read, so set the options here.

Why do I get a syntax error?

Prettier must parse the code before formatting it. Check the reported line and column, and make sure the selected language matches your code.

Can it format Python, Java or PHP?

No. Those need third-party Prettier plugins that are not included. Use the SQL Formatter for SQL.

Does it change what my code does?

No. Prettier only changes formatting such as whitespace, line breaks, quotes and optional semicolons.

Is my code uploaded?

No. Formatting happens entirely in your browser.

Related tools