Universal Code Formatter

Paste a snippet whose language you have not named. Auto-detect ranks the match. Format rebuilds indent inside this tab. A low-confidence guess is flagged before you copy.

Indent
waiting for input
Your pasteEdit freely
FormattedRead only
Paste code on the left, then hit Format. Nothing leaves this tab.

Eighteen languages share a Format button on this page. They do not share a grammar. A brace in Java opens a block. A brace in JSON opens an object. A colon in Python opens a suite. The same colon in YAML starts a mapping. Treating those as one problem is why most format-anything pages quietly wreck one of the files you paste.

This universal code formatter is a desk with five printers behind the button. Not a style guide.

Pick a language or leave Auto-detect on. Indent is rebuilt inside the tab. Nothing is uploaded. The 2 MB ceiling is real. A whole repository belongs in Prettier, Black, gofmt, or rustfmt sitting on disk, not here.

The guess chip is a ranking, not a compiler

Auto-detect scores fragments against a list of signals. def plus a colon leans Python. <?php is PHP. An opening { as the first non-space character plus a successful JSON parse is JSON. Confidence is the gap between the winner and the runner-up.

JavaScript and TypeScript share most of those signals. C and C++ share #include. A YAML mapping looks a lot like a Python keyword-argument list if you only count colons.

When the chip reads low confidence, read the output before you keep the result. Better: pick the language yourself. The ranking is a convenience for a paste whose origin you forgot. The ranking is not a substitute for knowing what you copied.

Split the clipboard before you hit Format. Auto-detect scores the whole paste as one document. A stack trace glued to a config file produces a confident wrong language more often than a useful indent.

Five printers sit behind one button

One Format click does not run one algorithm. The language pick, or the guess, chooses a printer. Indent width is the only shared setting, 2 spaces, 4 spaces, or a tab.

Brace walker
JavaScript, TypeScript, Java, C, C++, C#, PHP, Go, Rust. Indent follows { }, ( ), [ ]. Strings and comments are masked so a brace inside "{ ok }" never moves the counter. Preprocessor lines starting with # stay flush left in C, C++, and C#.
Keyword walker
Ruby and Lua. Indent follows def, function, if, do, class down to end. A missing end leaves a warning on the status bar. Identifiers are never rewritten.
Space rescale
Python and YAML. No braces to count. Leading width is measured, a step is inferred, every line is remapped onto the unit you picked. Body text stays character for character.
Markup
HTML and XML. Nesting of tags. Content inside <script> is handed to the JavaScript walker. Content inside <style> is handed to the CSS walker. <pre>, <textarea>, and CDATA stay as typed, because whitespace there is data.
Style
CSS and SCSS. Rules and declarations split onto their own lines. Comments collapse to one line. Declarations pick up a space after the colon.
SQL
Clauses land on their own lines: SELECT, FROM, WHERE, joins, GROUP BY, ORDER BY. Quoted identifiers stay quoted. Parentheses around a subquery add a level.
JSON
The only printer allowed to refuse. JSON.stringify pretty-prints a successful parse. A failure prints the parser message. Values do not move. Trailing commas are errors, not repairs.

JSON is the only printer allowed to refuse

Every other engine still emits a best-effort indent after a warning. Unbalanced brackets in JavaScript, unpaired end in Ruby, mixed tabs in Python: the right pane fills anyway. The status bar is the part to read. A warning there means the right pane is a sketch, not a file you commit.

JSON does the opposite. Parse fails, the right pane stays empty, the status bar quotes the token the parser rejected. A leading HTTP/1.1 200 OK line from curl -i is the usual cause. Peel the headers off, or open the API response formatter, which strips status lines, XSSI guards, and double-encoded payloads before parsing.

Minified source is exploded first

A webpack dump on one line. A SQL query copied from a log. A CSS file with every rule jammed together.

If the average live line is longer than 110 characters, or any line is longer than 240, the brace engine splits on {, }, and ; before indenting. Strings are masked, so a semicolon inside "a;b" does not start a new line.

What landed on the clipboard
const load=(id)=>{const r=fetch("https://api.toolexe.com/v2/invoices/"+id);return r.then(x=>x.json());}
What the brace walker emits
const load = (id) => {const r = fetch("https://api.toolexe.com/v2/invoices/" + id);
return r.then(x => x.json());}

Spacing around = and => in the sample above is already in the source. The walker does not insert operator spaces. Indent is the job. Operator style belongs to a language page, Prettier for JavaScript, the Python formatter for PEP 8.

Python and YAML refuse to count braces

Python has no braces to count. Indentation is the block structure. The space engine finds the greatest common divisor of existing leading widths, then remaps each line onto the unit you picked. A file written with three-space indent, a file written with tabs, a file where two people disagreed, all three land on the same grid.

The cost shows up on the status bar. No consistent step? Nesting is read one column at a time. Tabs mixed with spaces? The rescale treats one tab as four columns. If your editor used eight, the result looks wrong on purpose, so you notice.

YAML follows the same rescale, with one extra lock. A line ending in | or > starts a block scalar. Lines indented further than the parent stay untouched. The spaces inside a literal block are content. Strip them and the string your config parser returns changes.

Load the sample while Python is selected, or while Auto-detect is on with a def in the pane, to see the rescale. Do not expect keyword spacing. total=0 stays total=0. For total = 0, open the Python page.

Leave this desk once the language is known

A dedicated formatter knows more than indent. Use this page for a paste whose language you have not decided, a snippet from chat, a file you need readable before you pick a desk. Do not use this page as a repository formatter. There is no .prettierrc. There is no gofmt fidelity. There is no rustfmt edition flag.

PHP mixed with HTML is the awkward case. The brace walker sees PHP. The markup walker sees HTML. A file with both, <?php in the middle of a template, gets one printer. Expect the other half to look worse. Split the regions, or open the PHP beautifier when the file is mostly PHP.

Two megabytes is the honest stop

Formatting runs in JavaScript inside this tab. Closing the tab drops both buffers. There is no account, no paste history, no URL fetch. A private schema, a production query, a customer dump, none of those leave the machine.

Pastes over 2 MB are refused. Ace holds the whole string in memory twice, once per pane. A 40 MB SQL dump belongs in sqlformat or pg_format on your machine. The refusal is the feature. A tab trying to pretty-print a warehouse export will lock the browser before the indent finishes.

Read the guess chip. Read the status bar. Copy only after both look boring.

Questions the status bar does not answer

What shows up after a mixed paste, a minified dump, or a JSON parse failure.

Why did auto-detect call my TypeScript file JavaScript?

Most TypeScript looks like JavaScript until an interface, a type alias, or an annotation shows up. Auto-detect scores signals. Without those, JavaScript wins. Pick TypeScript in the language menu when you know the file. The guess chip then reads your choice instead of a rank.

The status bar says brackets do not balance. Do I commit the right pane?

No. The brace walker still emits indent after a warning. Remaining levels are a guess past the first unmatched bracket. Fix the missing brace on the left, then Format again. JSON is the exception: a parse failure leaves the right pane empty on purpose.

Why did Python indent change while operators stayed cramped?

This page remaps leading whitespace. Operator spacing is PEP 8 work, not indent work. total=0 stays total=0. Open the Python formatter when you want spaces around assignment, tight keyword arguments, and blank lines between top-level definitions.

Is the paste sent anywhere?

No. Detection and formatting run in this tab. Nothing is uploaded, stored, or logged. Closing the tab drops both editors. Save a download if you want a copy, because refresh clears the buffers too.

JSON failed at line 1, column 1. What sits in front of the brace?

Usually an HTTP status line copied from curl -i, an XSSI guard of the form )]} plus a quote, or a byte-order mark you cannot see. Peel the prefix off here, or paste the raw response into the API response formatter, which strips those wrappers before parsing.

Why is the YAML block after a pipe still a mess?

A line ending in | or > starts a literal or folded scalar. Lines indented further than the parent are content, so they are left alone. Formatting them would change the string your parser returns. Only the mapping around the block is rescaled.

Should a repository replace Prettier, Black, or gofmt with this page?

No. This desk has no project config, no import sorter, no line wrapper, no edition flag. Use this desk to read a paste. Put the real formatter in the repo so every file lands on the same rules without opening a browser.

Auto-detect picked JSON for a JavaScript object literal. Why?

A successful JSON.parse on a paste starting with { is scored as JSON. Unquoted keys, trailing commas, and comments fail JSON and fall through to JavaScript. If your literal uses unquoted keys, pick JavaScript yourself so the brace walker runs instead of the JSON printer.