Code formatter (multi-language)
One entry point for common languages: JavaScript / TypeScript (brace-based line breaks, statement splits, space after commas), JSON (real parse then re-indent), CSS (selectors and declarations on separate lines), HTML / XML (tag indentation with pre/script/style preserved) and SQL (clause keywords upper-cased and broken onto new lines). The language can be chosen or auto-detected, and string / template contents are never modified. Boundary: this is a compact formatter, not a tokenizer-grade one — JSX or dialect function bodies are indented conservatively; use the dedicated format-js / format-css tools for production output.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Result
The result can be copied directly.
Paste code to format it
Characters: 0 · Lines: 0 · Detected language: 0
What this tool does
- Expand minified one-liners into a readable layout.
- Normalise SQL clause casing and line breaks for review.
- Format JSON / CSS and paste it straight into a project.
Example
Input
function add(a,b){if(a){return a+b;}return b;}Output
function add(a, b){
if(a){
return a+b;
}
return b;
}String and template contents are preserved; JSON is really parsed, so invalid JSON reports an error instead of producing wrong indentation.
Frequently asked questions
How does this relate to format-js / format-css?
This is a compact multi-language entry point; the dedicated tools go deeper per language (JSX, nested media queries, SQL dialects). Use this for quick snippets and the dedicated tools for whole files.
Will my strings be modified?
No. Strings, template literals and comments are recognised lexically and only code regions are re-indented; JSON is parsed and re-serialised.
Is auto-detection reliable?
It is priority based: parseable JSON wins; SELECT / INSERT prefixes mean SQL; <!doctype or <html means HTML; CSS brace structure means CSS; everything else is JavaScript. Pick the language manually when needed.
Which languages use the indent option?
JSON and HTML / XML use it (0–8 spaces); JavaScript, CSS and SQL use a fixed 2-space structural indent.
Keywords:code formatterbeautify