Code formatter
Paste code and it lays itself out — language detected, no button to press.
Formatted code
How to use it
- Paste code into the box — it is formatted as you type; there is no button to press.
- The language is detected from the code. If the guess is wrong, pick one from the list; 2 or 4 spaces and 80, 100 or 120 columns reflow immediately.
- Copy the result or download it with the right extension (.js, .ts, .json, .py …).
Example
Input
function greet(user){if(!user){return "Hello, guest";}const tags=["new","active"];return `Hello, ${user.name}!`;}
export default greet;Formatted
function greet(user) {
if (!user) {
return "Hello, guest";
}
const tags = ["new", "active"];
return `Hello, ${user.name}!`;
}
export default greet;Formatted with the default rules (2 spaces, 80 columns). Prettier adds semicolons and double quotes; the template literal and the guest fallback are unchanged.
Rules, limits and known issues
- Formatting changes whitespace and the formatter’s own normalizations (quotes, semicolons, trailing commas); it never executes code, sorts keys or renames identifiers. Strings keep their contents.
- Engines: Prettier for JavaScript, TypeScript, JSON, CSS, SCSS, Less, HTML, Vue and GraphQL; Ruff (Black-compatible) for Python. Only the engine for the current language is downloaded, on first use, and the browser caches it.
- Auto-detect is a heuristic. A snippet that starts with a tag may be read as HTML even if it is JSX; pick JavaScript or TypeScript manually. A JSON-looking object that is not valid JSON falls back to JavaScript.
- Manual selection is authoritative: choosing CSS never silently formats as SCSS. TypeScript tries .ts and then .tsx.
- JSON uses Prettier’s json parser, so short objects may stay on one line. For strict validation, key order or minify, use the JSON toolbox. Duplicate keys keep the last value, as JSON.parse does.
- Prettier’s default style is fixed: double quotes, semicolons, trailing commas where valid. .prettierrc and .editorconfig are not read and there are no quote or semicolon options. Python uses double quotes and respects magic trailing commas (Ruff/Black).
- HTML whitespace follows htmlWhitespaceSensitivity: css, so spaces around inline elements may differ from the source. Markdown, YAML and XML are not supported; the Markdown editor, config converter and XML formatter cover them.
- Output is LF with no trailing newline, and formatting is idempotent. Above 200,000 characters the result updates about 0.6 s after you stop typing; formatting runs in a Web Worker and the text is never uploaded, put in the URL or stored.
Related tools
What people usually need next, once the code is readable.