Code formatter
Format or minify HTML, CSS, SCSS, Less, JavaScript, TypeScript, JSON, Markdown, YAML, XML, SQL, C, C++, C#, Java, PHP, Python and nginx configuration.
Process locally
Files stay in this browser session. Closing or clearing releases them.
Add text
Type or paste the text to process
Adjust settings
Optional: Language, Action, Indent and more
Run
Processes in this browser; cancel at any time
About this tool
Format or minify source code. Paste a minified script to make it readable again, tidy up a messy SQL query before a code review, or shrink HTML, CSS or JavaScript before putting it on a page. Supported languages are HTML, CSS, SCSS, Less, JavaScript, TypeScript, JSON, Markdown, YAML, XML, SQL, C, C++, C#, Java, PHP, Python and nginx configuration.
Formatting uses Prettier for the web languages and PHP, sql-formatter with 13 SQL dialects, clang-format for C, C++, C# and Java, and Ruff for Python. Minifying is available for HTML, CSS, JavaScript, JSON and XML. Up to 2 MB of code is processed right in your browser, and nothing is uploaded.
How to use it
- Type or paste your code, or select “Use example” to load a one-line JavaScript snippet.
- Choose the “Language” and the “Action”: “Format” or “Minify (HTML, CSS, JavaScript, JSON, XML)”.
- Set the “Indent” and “Line width” if you need to. For SQL, pick the “SQL dialect” and the case of “SQL keywords”; for C, C++, C# and Java, pick a “C, C++, C# and Java style”.
- Select “Run”. If the code cannot be parsed, the parser’s error message is shown instead.
- Preview the result and download it. The file keeps the language’s extension, such as formatted.js or minified.css.
Formats and limits
- Input
- Text
- Output
- Text
- Size limit
- 2 MB
- Settings
- Language; Action (Format, Minify); Indent (Language convention, 2 spaces, 4 spaces, Tab); Line width; C, C++, C# and Java style (Google, LLVM, Chromium, Mozilla, WebKit, Microsoft, GNU); SQL dialect; SQL keywords (As written, UPPER CASE, lower case)
- Privacy
- Files stay in the current browser session. No file bytes are uploaded.
- Price
- Free, no sign-up
Common questions
Which languages can be minified?
Only HTML, CSS, JavaScript, JSON and XML; choosing minify for any other language stops with an error. JavaScript is compressed with terser, which also shortens variable names, and CSS with csso. HTML loses its comments and the whitespace between blocks and has its inline CSS and scripts minified, while XML loses comments and whitespace between tags.
What does the “Language convention” indent use?
Python, Java, C# and PHP get 4 spaces, and every other language gets 2. Choose “2 spaces”, “4 spaces” or “Tab” to override it.
What line width is used when it is set to 0?
80 characters for the languages Prettier formats, 88 for Python, and the chosen style’s own limit for C, C++, C# and Java. For SQL, a width above 0 limits how long an expression may stay on one line, up to 120. XML and nginx configuration ignore the line width.
Why did my JavaScript get double quotes and semicolons?
JavaScript and TypeScript are printed in Prettier’s default style, which prefers double quotes and ends statements with semicolons. Only the indent and line width can be changed here.
Are comments kept in XML and nginx configuration?
Yes, when formatting. XML comments, CDATA sections and processing instructions stay as written, and an element holding only text stays on one line; nginx configuration keeps its comments and quoting, with one directive per line. Minifying XML removes the comments.
Related tools
JSON to code types
Generate TypeScript interfaces, C# classes, Java records, Go structs, Rust serde structs or Python dataclasses from sample JSON. Fields missing from some samples become optional.
HTML, CSS and JavaScript runner
Write HTML, CSS and JavaScript and see the page live with its console output, in an isolated frame.
JSON, YAML and XML converter
Validate, pretty-print or convert between JSON, YAML and XML for their shared subset. External entities and custom tags are rejected.
Markdown editor
Write Markdown with a live preview, then download it as Markdown or a styled HTML page.
HTML tag filter
Strip HTML tags to get readable text, or keep the tags and remove their attributes; chosen tags or attributes can stay. Scripts never run.
Text to HTML table
Turn CSV, tab-separated text copied from Excel, or text split by spaces or a custom character into an HTML table.