Developer Tools
Code Formatter
Format HTML, CSS, JavaScript, TypeScript, Python, JSON, SQL, and Markdown code.
About the code formatter
Pick a language, paste your code and click Format. HTML, CSS, JavaScript, TypeScript, JSON and Markdown go through Prettier 3, the open source formatter many teams run in their editors, and it all happens in your browser. SQL uses the sql-formatter library, and Python gets a simpler indentation pass. The result is highlighted and ready to copy. Prettier runs with its default settings: lines wrap at 80 characters, indentation is 2 spaces, strings get double quotes, statements end with semicolons and multi-line lists get trailing commas. There is no settings panel. Prettier rebuilds the code from its syntax tree, so it can change quotes, parentheses, semicolons and line breaks, but not what the code does. If the code has a syntax error, nothing is formatted and you see the parser's message, usually with a line and column. The Python option only re-indents: every line after one ending in a colon moves in four spaces, and else, elif, except and finally step back out. It can't tell where a block ends in other cases, so for real Python formatting use a dedicated tool like Black.
Frequently asked questions
Will it change my code logic?
Not for the Prettier languages. Prettier only changes layout: whitespace, line breaks, quotes, semicolons and optional parentheses, and the program behaves the same afterwards. Python is different, because indentation is part of the logic there, so check the re-indented result before you run it.
Can I configure tab width and quote style?
Not on this page. It always uses Prettier's defaults of 2 spaces, double quotes, semicolons and an 80 character line width. If your project uses other settings, run Prettier locally with your own .prettierrc file.
Which SQL dialect does it use?
The standard SQL mode of the sql-formatter library. It keeps your keywords as you typed them and puts each clause, like SELECT, FROM and WHERE, on its own line with the columns indented. Common queries format well; syntax that exists in only one database may not.
Is my code uploaded?
No. Prettier and sql-formatter are loaded into the page and run in your browser, so the code stays on your device.