XML / JSON / SQL Code Formatter

Paste XML, JSON, or SQL and get clean, indented output in one click - in your browser.

Formatted output
Indent
Runs in your browser - nothing is uploaded.

What is a code formatter?

A code formatter takes source that is minified or carelessly indented and rewrites it with consistent line breaks and indentation, so the structure is obvious at a glance. This hub handles the three formats web and data work touch most often. XML is a tree of nested elements - a formatter puts each element on its own line and indents children under their parent. JSON shares that nested shape, built from objects and arrays, and reads far more easily once each key sits on its own indented line. SQL is different: it is a sequence of clauses, so formatting it means breaking the query at SELECT, FROM, WHERE, JOIN, and the other clause keywords and lining them up. In every case the meaning of the code is unchanged - only its layout improves - and all of it happens in your browser, with nothing sent to a server.

How to use the code formatter

  1. Choose the language. Click XML, JSON, or SQL in the format selector at the top of the tool. The formatter switches its parser and indent rules to match the language you picked.
  2. Paste your code. Paste the raw, minified, or broken-indented code into the input panel on the left. Nothing is uploaded and nothing leaves the page - the input stays in your browser until you run it in the next step.
  3. Click Format. Click the Format button to apply indentation and line breaks. Use the indent chip to switch between 2 spaces, 4 spaces, or a tab. For XML and JSON you can also click Minify to strip all whitespace.
  4. Copy or download the result. Click Copy to put the formatted code on your clipboard, or Download to save it as a file. Everything stays in your browser - nothing is logged or stored.

Frequently asked questions

What does a code formatter do?
A code formatter re-indents and restructures code so that nesting is visible at a glance. It does not change what the code does - a formatted XML document and its minified version are identical to a parser. The benefit is purely for human readers: aligned tags, consistent spacing, and each element on its own line make it far easier to spot a missing closing tag, a misquoted attribute, or a logic error in a long query.
How do I format XML online?
Paste your XML into this tool, make sure the XML tab is selected, and click Format. The formatter parses the document using the browser's built-in DOMParser and re-serialises it with consistent 2-space (or 4-space, or tab) indentation. If the XML is not well-formed - for example, an unclosed tag or an unescaped ampersand - the tool shows the parse error inline so you know exactly what to fix.
What is the difference between formatting JSON and minifying it?
Formatting adds whitespace - newlines and indentation - to make the structure readable. Minifying removes all non-essential whitespace to produce the smallest possible string. Both produce JSON that is semantically identical: {"a":1} and { "a": 1 } mean the same thing to any JSON parser. Use formatted output for debugging or documentation; use minified output when shaving bytes from an API payload or a config file.
Can I format SQL queries here?
Yes. Select the SQL tab, paste your query, and click Format. The formatter uppercases SQL keywords (SELECT, FROM, WHERE, JOIN, ON, GROUP BY, ORDER BY), puts each clause on its own line, and indents AND, OR, and ON conditions one level under the clause they belong to, so a long query is easy to scan. It is a layout pass, not a parser: it does not track parenthesis depth, so deeply nested subqueries and multi-line CASE expressions are not re-indented for you. Vendor-specific syntax (for example, Oracle CONNECT BY hierarchical queries) is left as written, but the keyword casing and clause breaks still apply.
Does this formatter validate my code as well as format it?
For XML and JSON, yes - the formatter parses the code before it indents it, so a parse error means it cannot format the input and it tells you why: the line number, the unexpected character, or the missing bracket. For SQL, the tool applies formatting rules without a full parse, so syntactically invalid SQL will still be indented - check the output carefully. If you need strict SQL validation, run the query against your database directly.