HandyTools

Code formatter

Paste code, pick a language, and reformat it with consistent indentation — JSON, YAML, HTML, CSS, Markdown, JavaScript, TypeScript, and SQL.

Input
Output

Files are processed in your browser

How it works

Format JSON, YAML, HTML, CSS, Markdown, JS/TS, and SQL.

  1. 01

    Paste or type your code.

  2. 02

    Pick the language and an indent width.

  3. 03

    Click Format, then copy the tidied result.

FAQ

Which languages are supported, and how does it format them?

JSON, YAML, HTML, CSS, Markdown, JavaScript, and TypeScript are formatted by Prettier; SQL by sql-formatter. Both are the same engines used in real editors and toolchains, so the output matches what you would get running them locally — this tool just runs them in your browser.

What does formatting actually change?

It re-indents and re-wraps code to a consistent style without changing what the code does: whitespace, line breaks, and quote or bracket placement are normalized, but values, keys, and logic stay the same. It is layout only, not a rewrite.

Why does it report an error instead of formatting?

The formatter has to parse the code first, so it will refuse to format input with a syntax error — a missing bracket, an unclosed string, an invalid token. The message points at where parsing failed. Fix the syntax and format again; a clean parse is also a quick sanity check that the code is well-formed.

Is my code uploaded?

No. The formatting engine is downloaded to your browser the first time you format, and all parsing and printing happen locally. Your code is never sent to this site or any third party, and it clears when you refresh or leave.

One formatter, many languages

Every language has its own idea of tidy — JSON wants aligned braces, SQL wants keywords on their own lines, Markdown wants single blank lines between blocks. Rather than reinvent each, this tool runs the engines the ecosystems already trust: Prettier for JSON, YAML, HTML, CSS, Markdown, JavaScript, and TypeScript, and sql-formatter for SQL. Pick the language, and it applies that language's conventions.

Formatting is layout, not a rewrite

A formatter re-prints your code with consistent indentation, line breaks, and spacing, but it does not change behavior: the data, keys, values, and logic are exactly what you put in. That also makes it a fast correctness check — because it must parse the input first, a successful format means the syntax is valid, and an error points straight at the spot that would not parse. Use it to make diffs clean, settle indentation arguments, or just make a pasted blob readable.

The engine loads only when you format

Formatting engines are sizable, so this page does not ship them up front. The first time you click Format, the browser fetches the engine for that language and caches it; nothing loads until you ask. And because everything runs in your browser, code you would never paste into an unknown online service — internal config, a query with real table names, an unreleased snippet — stays on your machine.