JavaScript Formatter
Pretty-print minified or messy JavaScript with consistent indentation, spacing, and line breaks.
Formatted live as you type. Nothing leaves your browser. Plain JavaScript only, not JSX or TypeScript.
Format
Indent
Wrap long lines
How to format JavaScript online
Paste your JavaScript
Drop a whole file or a single function into the input. It is reformatted automatically a moment after you stop typing.
Pick your indentation
Choose 2 spaces, 4 spaces, or a tab, and optionally wrap long lines at 80 or 120 columns.
Copy the result
The formatted script appears in the output area, and Copy JavaScript puts the whole thing on your clipboard.
Why use this tool
Unminifies one-line scripts
A bundled or minified file collapsed onto a single line is reprinted as statements, blocks, and functions you can actually read.
Indent size you choose
Format with 2 spaces, 4 spaces, or a tab, so the output matches the style guide of the project you are pasting into.
Optional line wrapping
Leave long lines alone, or wrap them at 80 or 120 columns for code that has to fit a narrow review pane.
Broken code is called out
An unclosed brace, a stray bracket, or an unterminated string is reported with the line it starts on instead of producing scrambled output.
Formatting only, never rewriting
Whitespace and line breaks change; your statements, names, and comments do not. The behaviour of the script is left exactly as you pasted it.
Code stays on your device
Formatting runs in your browser. Nothing you paste is uploaded, which matters when the script belongs to a client or an unreleased product.
About this tool
This JavaScript formatter takes code that has been minified, hand-mangled, or merged by three people with three different habits, and reprints it with one consistent shape: one statement per line, blocks indented by the amount you pick, and predictable spacing around operators, commas, and braces. Formatting runs automatically a moment after you stop typing, so reading a minified file is paste, wait a beat, copy.
Indentation is the main control: 2 spaces, 4 spaces, or a real tab. Long lines can be left exactly as they are, which is usually what you want, or wrapped at 80 or 120 columns when the code has to fit a narrow diff view. Blank lines you wrote are preserved, with long runs collapsed, so the structure you intended survives the trip. Nothing is renamed, reordered, or removed; only whitespace and line breaks change.
Before formatting, the input is checked for the structural mistakes that actually break a paste: an unclosed brace, a closing bracket that matches nothing, an unterminated string or template. Those are reported with the line number they start on rather than silently producing nonsense. This is a formatter and not a validator, so a clean result is not proof the script runs. JSX and TypeScript are out of scope; both need their own parsers, and feeding them in here produces poor output. For the rest of a front-end payload, see the CSS beautifier, the HTML formatter, and the JSON formatter.
Frequently asked questions
- Does this work on minified JavaScript?
- Yes. That is the main use. A file that ships as one very long line is reprinted as indented statements and blocks. Names that were shortened during minification stay short, because the original names are gone from the file and cannot be recovered by formatting.
- Can I format JSX or TypeScript?
- No. This handles plain JavaScript. JSX tags and TypeScript type annotations need their own parsers, so pasting them here gives poor results. Strip the types or use a formatter built for those languages instead.
- What happens if my code has a syntax error?
- Structural problems are reported with the line they start on: an unclosed brace or bracket, a stray closing bracket, an unterminated string, template, or comment. Other mistakes are not caught, since this is a formatter rather than a validator, so a clean result does not mean the script runs.
- Does formatting change what my code does?
- No. Only whitespace and line breaks are rewritten. Statements, variable names, comments, and string contents are left alone, so the formatted output behaves exactly like the input.
- Is my code uploaded anywhere?
- No. Formatting happens entirely in your browser and the script never leaves your device. There is also no fixed size limit, since processing is bounded by your device memory rather than an upload cap.
Related tools
CSS Beautifier & Minifier
Beautify minified CSS into readable rules, or strip comments and whitespace, with indent control and a size readout.
HTML Formatter & Beautifier
Beautify messy or minified HTML with indent, line wrap, and line break control.
JSON Formatter & Validator
Pretty-print, minify, or explore JSON as a collapsible tree, with syntax errors shown inline.
API Key Generator
Generate cryptographically random API keys and tokens in hex, base62, or base64url, with control over length, an optional prefix, and bulk output.
ASCII Table Reference
The full ASCII character set with decimal, hex, octal, binary, and HTML codes. Search by code, character, or name.
Atbash Cipher
Mirror the alphabet so A swaps with Z, B with Y, and so on. Atbash is its own inverse, so one field both encodes and decodes as you type.