Code Formatter

New

Beautify or minify JSON, CSS, HTML, SQL and XML in one tool.

How was your experience with this tool?

Found a bug? Missing a feature? Tell us — it takes 10 seconds.

See how it works

Watch a quick simulation of this tool in action — no file needed.

How to use Code Formatter

Follow these steps — everything happens instantly in your browser.

  1. 1

    Step 1. Pick the language — JS, CSS, HTML, JSON, SQL or XML.

  2. 2

    Step 2. Choose indent (2 or 4 spaces).

  3. 3

    Step 3. Click Beautify or Minify.

  4. 4

    Step 4. Copy the result.

Code Formatter: Beautify and Minify JSON, CSS, HTML, and SQL

Why this matters

Developers switch between JSON, CSS, HTML, SQL, and XML constantly throughout a typical workday, and each format arrives in a different state of readability. API responses come as single-line JSON blobs. Legacy codebases contain CSS with zero indentation. Generated HTML from template engines is a mess of collapsed tags. Copy-pasted SQL from chat windows loses all clause breaks. Running a different formatter for each language means opening five browser tabs or installing five VS Code extensions, which is overhead nobody wants.

This tool consolidates beautification and minification for all five languages into one interface. Each language has a dedicated, hand-written formatter rather than a generic Prettier wrapper, which means the output follows language-specific conventions — SQL keywords are uppercased and clauses get their own lines, JSON keys are sorted consistently, and XML preserves attribute ordering. The 2-space or 4-space indent toggle lets you match your project's style guide instantly, and the minify path strips all unnecessary whitespace while preserving string content and comment safety for CSS, HTML, and XML.

Supported languages and modes

| Language | Beautify features | Minify behavior |

| --- | --- | --- |

| JSON | Indented keys, sorted order | Single line, no whitespace |

| CSS | Rule-per-line, nested braces | Stripped whitespace and comments |

| HTML | Indented tags, readable attrs | Collapsed tags, safe string content |

| SQL | Uppercased keywords, clause breaks | Compressed clauses |

| XML | Indented elements, attr formatting | Stripped whitespace and comments |

How to use it

Paste your code into the input area.

Select the language from the dropdown: JSON, CSS, HTML, SQL, or XML.

Choose your indent preference: 2 spaces or 4 spaces.

Click Beautify to format for readability or Minify to compress for production.

Testing your result

After beautifying, paste the output into your editor and verify that it renders or parses identically to the original. For JSON, run it through a parser to confirm valid syntax — the beautifier will expose any malformed input that was hidden in a single line. For CSS, load the beautified version in a browser and check that all styles apply correctly. For SQL, paste it into a query runner and confirm it executes the same query. The minified output should be functionally identical to the input; the only difference is the removal of whitespace and comments where safe.

Common mistakes

Pasting JavaScript into the formatter and selecting JSON — JS objects are not valid JSON when they contain unquoted keys or trailing commas.

Assuming minified SQL will run correctly without testing, since aggressive whitespace removal can occasionally break complex nested queries.

Forgetting to select the correct language before clicking Beautify, which applies the wrong parsing rules to your input.

Edge cases and limitations

The SQL formatter is dialect-agnostic: it uppercases recognized keywords and breaks lines at clause boundaries, which works well for MySQL, PostgreSQL, SQLite, SQL Server, and Oracle but will not handle dialect-specific syntax like T-SQL `BEGIN TRY` blocks perfectly. The formatter does not support JavaScript beautification — use the dedicated JS minifier for that. Very large files (above 1 MB of text) may feel sluggish because the formatter processes the entire string synchronously in the browser. All processing is local, so pasting proprietary code is safe.

Real-world use cases

Debugging a minified JSON API response by beautifying it into a readable, indented structure.

Cleaning up generated HTML from a CMS export before hand-editing the template.

Minifying inline CSS and HTML snippets before pasting them into a production email template.

Frequently asked questions

Q: Why a multi-language formatter?

A: Most formatters specialise in one language. This gives you a single tool for the common case — switching contexts without swapping tools.

Q: Is the SQL formatter dialect-aware?

A: It uppercases recognized keywords and breaks lines at clause boundaries — works well for MySQL, PostgreSQL, SQLite, SQL Server and Oracle.

Q: Are strings preserved during minification?

A: Yes — CSS, HTML and XML minifiers preserve string content and only strip whitespace and comments where safe.

Q: Is my code uploaded?

A: No. Formatting happens entirely in your browser.

Q: Does it support JavaScript?

A: Not in this tool. Use the dedicated JS Minifier for JavaScript beautification and minification.

Start using it now

Beautify or minify your code across five languages with the Code Formatter. For JSON-specific formatting, try the JSON Formatter. For CSS-specific work, the CSS Minifier & Beautifier offers deeper options. Dedicated tools for JS, SQL, and XML are also available.

Want the extended step-by-step tutorial? Read it here.

Why use this tool

Private by design

All processing happens locally in your browser. Open DevTools → Network and you'll see zero file uploads. Ever.

Instant

No upload wait, no queue, no server round-trip. Results appear the moment you drop a file.

Free & unlimited

No accounts, no watermarks, no daily caps. Use it as many times as you like, forever.

Works everywhere

Desktop, tablet or phone — every tool is responsive and installable as a PWA for offline use.

Frequently asked questions

Everything you might want to know about code formatter.

❤️ This tool is free — forever.

Sharing it helps more people discover it, and ad revenue from visitors is what keeps it free. No accounts, no catch.

Want to learn more?

Read our complete Code Formatter tutorial with tips, use cases, and FAQs.