Code Formatter

Paste minified or messy HTML, CSS, JavaScript, or JSON and get it cleanly re-indented. Auto-detect the language or pick one, choose spaces or tabs — all locally, nothing is uploaded.

Try:
Formatted code

What this tool does

Paste a minified or messy HTML, CSS, JavaScript, or JSON snippet and get it back cleanly re-indented and line-broken. Leave the language on auto to detect it from the snippet, or pick one explicitly when auto-detect guesses wrong. Choose how many spaces to indent per nesting level, or switch to tabs.

Everything runs locally in your browser. For HTML, CSS, and JavaScript only the whitespace and line breaks change — nothing is renamed, reordered, or dropped. JSON is parsed, validated, and re-serialized with key order preserved.

Languages

Worked example

Input (minified JSON):

{"name":"gizza","tags":["a","b"],"nested":{"x":1}}

Language: auto · Indent: 2 spaces

Output:

{
  "name": "gizza",
  "tags": [
    "a",
    "b"
  ],
  "nested": {
    "x": 1
  }
}

Switch Indent character to tab (or raise the space count to 4) to change the indentation width; switch Language to css, html, or javascript to format those instead.

Limits and edge cases

FAQ

Does formatting change what my code does?

No. For HTML, CSS, and JavaScript only whitespace and line breaks change — nothing is renamed, reordered, or removed. JSON is parsed and re-serialized with the original key order preserved, so the data is identical.

What happens if the language auto-detect guesses wrong?

Set the Language field to html, css, javascript, or json instead of auto. Auto-detect reliably recognizes HTML (a leading <) and valid JSON, but CSS and JavaScript can look similar, so choose one explicitly when needed.

Can I indent with tabs instead of spaces?

Yes. Set Indent character to tab and each nesting level is indented with a single tab. The spaces-per-level number is ignored in tab mode. For spaces, choose any width from 1 to 8.

Why did my JSON fail to format?

The JSON formatter validates the input first, so anything that isn't standard JSON — trailing commas, // comments, single-quoted strings, or unquoted keys — is reported as an error rather than being guessed at. Fix the reported issue, or pick a different language if the snippet isn't actually JSON.

Is my code uploaded anywhere?

No. The formatter runs entirely in your browser via WebAssembly. Your snippet never leaves your machine and there are no network requests.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool code-formatter "Paste HTML, CSS, JavaScript, or JSON…"

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/code-formatter/?code=Paste%20HTML%2C%20CSS%2C%20JavaScript%2C%20or%20JSON%E2%80%A6&language=auto&indent=2&indent_char=space

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.