Code Formatter
Format JavaScript, TypeScript, JSON, HTML or CSS with parser-aware indentation and downloads.
This tool runs entirely in your browser. Your data is never uploaded, never stored, and never leaves your device.
Format JavaScript, TypeScript, JSON, HTML or CSS with the correct parser, configurable indentation and local downloads.
How to use it
- 1Choose the source language and paste code or open a local file.
- 2Choose formatting settings and format the source.
- 3Review errors or the formatted result, then copy or download a separate file.
What happens to your data
Source is parsed locally, not uploaded or executed. Formatting is not a security audit, type check or program test.
Last updated October 2026
Format JavaScript, TypeScript, JSON, HTML or CSS with an explicit language choice. Paste code or open a local source file, select indentation, and review a consistently laid-out result before copying or downloading it. The formatter runs in your browser and never executes the code you provide.
Language selection matters. A JSON object is not a JavaScript statement, and a JavaScript array followed by a semicolon is not valid JSON. The separate JSON mode uses a JSON parser and output rules, while JavaScript and TypeScript use their own parsers. Choose the language of the input rather than treating every brace-delimited file as interchangeable.
Use this page for readable source formatting. For a searchable JSON tree, semantic JSON comparison or YAML documents with anchors, use the corresponding dedicated tools. Formatting is not minification, a security scan, a TypeScript type check or evidence that a program will run correctly.
How it works
The selected Prettier parser is loaded when it is needed. Input is limited to 100,000 characters, local UTF-8 files to 100 KB and formatted output to 500,000 characters. Syntax errors are displayed without producing a successful download. Source changes and settings changes invalidate the prior result, including when an earlier asynchronous formatting operation finishes later.
The formatter normalises presentation and may change quotes, semicolons, indentation, line wrapping and line endings according to the chosen language. Choose two or four spaces and a preferred width of 80, 100 or 120. A line-width preference is not a promise that every string or URL will fit that width. The original local file is not overwritten; save the result as a separate file and review a diff before applying it to a project.
HTML is formatted as source text, not inserted into the page as executable markup. Embedded languages are not internally reformatted, although HTML can adjust their surrounding indentation. Use JavaScript or CSS mode separately to format those snippets. Formatting does not load your project configuration, resolve imports, fetch remote scripts or install plugins. A framework-specific syntax outside the supported modes should be handled by that project's own formatter.
Worked example: format an object as JSON, not JavaScript
- Input
- {"ready":true}
- Result
- { "ready": true }
Select JSON and two-space indentation. This short object stays on one line, with a final newline and no JavaScript semicolon.
Common use cases
- Reading a compact JavaScript or TypeScript snippet
- Formatting JSON without turning it into JavaScript
- Reviewing HTML and CSS source before a code change
- Downloading a local formatted copy without executing the input
Frequently asked questions
Which language should I choose for JSON?+
Choose JSON, even when the file contains only an array or object. JavaScript allows syntax that JSON does not, so using a JavaScript parser can reject valid JSON or produce output that is no longer JSON.
Does this run or upload my code?+
No. It parses and formats locally. HTML remains text, JavaScript is not evaluated, and the tool does not follow imports or call endpoints mentioned in your source.
Will formatting prove my code works?+
No. A syntactically valid program can still contain type errors, incorrect logic or unsafe behaviour. Run your project's type checks and tests after reviewing the formatted changes.
Why did quotes or semicolons change?+
Prettier applies language-specific style rules. Formatting preserves supported program structure but is not byte-for-byte preservation. Compare the output with the source before replacing a file.
Is this a code minifier?+
No. The purpose is readability and consistent formatting. It does not bundle dependencies, optimise algorithms or promise smaller production code.
Standards and limitations
Used in these workflows
Related tools
JSON Formatter & Validator
Format, validate, and minify JSON with exact line errors, a searchable tree, and private processing.
Text Diff Checker
Compare two texts side by side. Highlight character, word, or line changes and download a private diff.
YAML Formatter & Validator
Format YAML with comments and anchors retained. Validate and download multi-document files.
SQL Formatter
SQL beautifier for 20 dialects with keyword case, spaces or tabs, copy and .sql download.