FormatterHQ

Code Formatters & Beautifiers

Pretty print and beautify source code in dozens of languages, from JSON and SQL to PHP, Python, Java and C++, with consistent indentation.

ActionScript Formatter Beautify ActionScript 3 code online with proper indentation. Angular Formatter Format Angular component templates with structural directives, bindings and pipes. Babel Formatter Format modern JavaScript and JSX using the Babel parser and Prettier. C Formatter Beautify C source code online with clang-format presets. C# Formatter Format C# code online with clang-format and the Microsoft, Google or LLVM style. C++ Formatter Beautify C++ code online with clang-format: Google, LLVM, Chromium and more. Code Syntax Highlighter Highlight source code as self-contained HTML with inline styles - paste the coloured snippet into blogs, e-mails or docs. CSS Formatter Beautify or minify CSS online. Expand compressed stylesheets into readable rules. CSS Pretty Print Opinionated CSS pretty print with Prettier: normalises case, leading zeros, quotes and semicolons so a team's stylesheets look alike. Flow Formatter Format JavaScript with Flow type annotations online using the Flow parser. GraphQL Formatter Beautify GraphQL queries, mutations, fragments and schema definitions online. Handlebars / Glimmer Formatter Format Handlebars, Glimmer and Ember templates online. HTML Formatter Beautify or minify HTML online. Fixes indentation of tags, inline CSS and scripts. HTML Pretty Print Opinionated HTML pretty print with Prettier: closes implied tags, enforces a line width and gives the same output for any input layout. Java Formatter Format Java source code online using clang-format with Google, Chromium and other styles. JavaScript Formatter Beautify or minify JavaScript online: fix indentation, spacing and line breaks of messy or minified JS code. JavaScript Pretty Print Opinionated JavaScript pretty print with Prettier: identical output for any input layout, with indent, width, semicolon and quote options. JSON Formatter Format, beautify and validate JSON online. Pretty print minified JSON with 2, 3, 4 space or tab indentation and pinpoint syntax errors. JSON Pretty Print Pretty print JSON online with a 4-space default, 2 or 3 spaces or tabs, and see the matching JavaScript, Python, PHP and jq commands. JSON Viewer & Beautifier View JSON as a collapsible tree and beautify it at the same time. Explore nested objects and arrays without losing your place. JSON5 Formatter Format and beautify JSON5 with comments, unquoted keys and trailing commas, or convert JSON5 to strict JSON. LESS Formatter Beautify LESS stylesheets online, including variables, mixins and nested rules. Lua Beautifier Format Lua scripts online: consistent indentation, spacing and line breaks. Lua Minifier Minify Lua scripts online by removing comments and whitespace. LWC Formatter Format Salesforce Lightning Web Components (LWC) HTML templates online. Markdown Formatter Clean up Markdown: consistent lists, headings, tables and code fences. MDX Formatter Format MDX documents that mix Markdown with JSX components. Objective-C Formatter Format Objective-C code online with clang-format. Perl Formatter Re-indent Perl scripts online so blocks and subs line up. PHP Formatter Format PHP code online following PER coding style, with modern PHP 8 syntax support. Protobuf Formatter Format Protocol Buffers (.proto) definitions online with clang-format. Python Formatter Format Python code online with Ruff, a fast Black-compatible formatter. React JSX Formatter Format React components and JSX online with Prettier. Ruby Formatter Re-indent Ruby code online so classes, methods and blocks line up correctly. SCSS Formatter Beautify SCSS stylesheets online with proper nesting and indentation. SOAP Formatter Format SOAP request and response envelopes online. Beautify headers and body, validate the XML and pinpoint errors. SQL Formatter Format SQL queries online for MySQL, PostgreSQL, SQL Server, Oracle, SQLite, BigQuery and more. SVG Formatter Beautify SVG markup online so paths, groups and attributes are readable. TOML Formatter Format TOML files online. Normalise spacing, tables and arrays of tables into clean, canonical TOML. TypeScript Formatter Format TypeScript code online with Prettier, including interfaces, generics, decorators and type annotations. Vue Formatter Format Vue single-file components: template, script and style blocks in one pass. WSDL Formatter Format WSDL files online. Beautify web service definitions with messages, port types, bindings and services neatly indented. XAML Beautifier Beautify XAML for WPF, UWP, WinUI, MAUI and Avalonia. Indent layouts, controls and bindings consistently and validate the markup. XML Formatter Format and beautify XML online with custom indentation. Validate structure, keep comments and CDATA, and spot errors by line. XML Pretty Print Pretty print XML in the browser, with matching commands for xmllint, xmlstarlet, Python and .NET when it belongs in a script. YAML Beautifier Clean up messy Kubernetes, Compose and CI YAML: consistent indentation and spacing, with comments and anchors kept as written. YAML Formatter Format YAML online with consistent indentation while keeping comments. Validate syntax and see the exact line of any error. YAML Pretty Print Pretty print YAML online and see the yq, PyYAML and js-yaml settings that give the same block style, key order and indent.

A code formatter for every language you use

Consistent formatting makes code easier to read, review and maintain. It also helps when you receive code in a bad state: minified bundles, one-line JSON, SQL from a log file or a snippet whose indentation was mangled by an email client. This collection brings a code formatter for each common language together in one place, most of them based on the same formatters that professional editors use.

Choosing the right formatter

If you want to present code rather than change it, the code syntax highlighter produces colored HTML for blogs and emails.

How to get the best results

  1. Pick the formatter for the exact language or dialect; a JSX file formats better with the React formatter than with the plain JavaScript one.
  2. Choose an indentation that matches your project (2 or 4 spaces, or tabs).
  3. If the formatter reports a syntax error, fix it first; formatters need parseable code.
  4. Compare before and after with the diff checker when you format code that others will review.

Formatting in teams

Online formatters are ideal for one-off jobs. For projects, add the same tool to your editor and continuous integration (Prettier for web languages, Black for Python, gofmt for Go and so on), so every commit is formatted automatically and style debates disappear from code reviews.

When a formatter saves the day

Formatting is the first step of almost every debugging session with unfamiliar code. A minified stack trace becomes navigable once the bundle is formatted, a failing configuration file often reveals a misplaced bracket as soon as it is indented, and a long SQL query that "sometimes returns duplicates" usually shows its missing join condition when each clause sits on its own line.

Good to know

  • Formatting changes whitespace and layout, not behavior. Python is the exception to be careful with, because indentation is part of its syntax.
  • Minifiers do the opposite of formatters; you can find them in the minifiers category.
  • Code is formatted in your browser, so proprietary code is not uploaded.

Frequently asked questions

What is the difference between a formatter and a beautifier?
They mean the same thing: tools that rewrite code with consistent indentation, spacing and line breaks so it is easier to read. Pretty printer is another common name.
Will formatting change how my code runs?
No. Formatters only change whitespace and layout. For whitespace-sensitive languages such as Python and YAML, the structure is preserved as parsed.
Why does the formatter report an error?
Formatters must parse your code first, so a syntax error such as a missing bracket stops them. The message points to the line to fix.
Can I choose tabs or spaces?
Most formatters offer an indentation option for 2 or 4 spaces or tabs, so the result matches your project style.