Read your code more clearly
JavaScript Beautifier
Turn compact JavaScript into readable code with consistent indentation and spacing. Paste a snippet or open a local file, then copy or download the result.
Code is processed in this page, with no upload or execution. Existing line breaks and literal text are preserved. Read the support limits.
Format JavaScript
UTF-8 only. Maximum 600,000 bytes and 150,000 code units. The file stays in your browser.
Processing limit: 150,000 UTF-16 code units. Oversized input stays intact but is not formatted. Press Ctrl+Enter or Cmd+Enter to format. Tab moves to the next control.
Read-only output. Formatting is not syntax validation or a security check.
- Input UTF-8 bytes
- 0
- Output UTF-8 bytes
- 0
- Input / output lines
- 0 / 0
Ready. Paste code or load the example.
How to use the beautifier
- Paste JavaScript without HTML script tags, or choose a UTF-8 local file.
- Select spaces or tabs. Expand layout opens blocks and separates explicit statements; existing layout only adjusts spacing and indentation.
- Beautify, review the result, then copy or download
beautified.js.
Changing input or settings clears the previous result so exports always match your last successful formatting run. Clear and reset removes both editors, clears the file choice and restores the default settings.
What the result tells you
The formatter checks literal boundaries and delimiter pairing, then verifies that the exact lexical items survived formatting. Success means a formatting pass completed; it does not establish that the program is valid JavaScript.
Byte counts measure UTF-8 text, not compressed transfer size. Line counts include a trailing empty line when present. Formatting normally increases size. Keep source maps and original files when inspecting minified bundles; variable names and removed comments cannot be recovered.
Supported code and limits
Handles ordinary JavaScript, modules, arrow functions, classes, private fields, optional chaining, nullish operators, common regular expressions, and nested template literals. Template literals, including their interpolation expressions, remain verbatim. Quotes, escapes, comments and existing line-break boundaries are retained.
This is a conservative lexical formatter, not a complete ECMAScript parser. It rejects slashes immediately after ), }, or contextual words such as await and yield. It also rejects a slash after a value-like item, such as a name or string, when a line break intervenes, including inside a comment. That includes some valid line-wrapped division and semicolonless statements. Distinguishing these cases from a regular expression needs more syntactic context; use a parser-based project formatter for them.
JSX/HTML, TypeScript, decorators, escaped identifier names, HTML-style comments and v-flag regular expressions are unsupported. Obvious extension syntax is rejected, but all invalid or unsupported programs cannot be detected without a parser. Limits are 150,000 input code units, 50,000 lexical items, 100 delimiter levels, 32 nested templates, 1,000,000 output code units and a 1.5-second cooperative processing deadline.
Preservation and privacy
Existing line terminators matter: return followed by a newline can behave differently from return value. New breaks are added only at selected structural boundaries. New whitespace uses LF; line endings inside literal and comment text stay untouched. The ECMAScript semicolon-insertion rules explain these cases.
Input is held in page memory. This tool sends no code, opens no remote URL, uses no local storage and never runs pasted code. The site's shared analytics are managed separately. Copy uses your browser's clipboard permission; if it is unavailable, Select output lets you copy manually. Review and test formatted code using your project's parser and tests before deploying it.