CalcCafe

JavaScript Pretty Print

Pretty-print and beautify JavaScript into clean, consistent code. It runs entirely on your device — nothing is uploaded.

Example

Pretty-print and beautify JavaScript into clean, consistent code.

How it works

Prettier re-formats your JavaScript with consistent indentation, spacing and line breaks.

Good to know

JavaScript Pretty Print takes messy, minified, or inconsistently styled JavaScript and rewrites it with uniform indentation, spacing, and line breaks. It runs the Prettier engine directly in your browser, so the code you paste is parsed and reformatted on your own machine rather than sent to a server. It is aimed at developers who need to make unfamiliar or compressed source readable, and at anyone reviewing snippets pulled from a build output, a Gist, or a Stack Overflow answer.

Reach for it when you want to inspect a one-line minified bundle, clean up code copied from somewhere that lost its formatting, or normalize a snippet before pasting it into a review or documentation. Because it reformats rather than just adding whitespace, the output reflects Prettier's opinionated style: consistent quote usage, trailing commas where appropriate, and predictable wrapping of long lines and function arguments.

To read the result, compare structure rather than logic: the tool never changes what your code does, only how it looks, so behavior, variable names, and execution order stay identical. If the input cannot be formatted, that almost always means it is not valid JavaScript — a syntax error such as an unclosed bracket or stray token will stop Prettier from parsing it, which makes this a quick informal way to sanity-check that a snippet is well-formed.

A practical caveat: this is a formatter, not a minifier, deobfuscator, or transpiler. It will expand minified code into readable lines but cannot restore original variable names that a minifier shortened to single letters, and it will not strip comments or rename identifiers. For TypeScript, JSX-heavy React files, or other syntaxes, use the matching dedicated tool so the correct parser is applied.

Frequently asked questions

Is my data uploaded anywhere?
No — everything runs in your browser. Your code never leaves your device, so it's safe for private work and runs offline once loaded.
Is this tool free?
Yes, completely free with no sign-up and no limits.

People also ask

What is the difference between pretty-printing and minifying JavaScript?
Pretty-printing expands code with indentation, spacing, and line breaks to make it readable, while minifying does the opposite by stripping whitespace and shortening names to make files smaller. Both preserve the code's behavior; they just optimize for different goals (readability versus file size).
Does formatting JavaScript change how the code runs?
No. A formatter only alters whitespace, line breaks, quote style, and similar cosmetic details. The logic, variable names, and execution order remain exactly the same, so the reformatted code behaves identically to the original.
Can this tool un-minify or deobfuscate JavaScript?
It can re-expand minified code into readable, indented lines, but it cannot recover the original variable or function names that a minifier replaced with short ones. It also does not reverse obfuscation techniques such as string encoding or control-flow flattening.
Why won't my JavaScript format?
The most common reason is a syntax error in the input, such as a missing bracket, an unclosed string, or a stray character, which prevents the parser from reading the code. Code written in a different syntax like TypeScript or JSX may also fail in a plain JavaScript formatter.
What engine does this formatter use?
This page uses Prettier, an open-source, opinionated code formatter, running entirely in the browser. Prettier applies a consistent style automatically rather than letting you tweak every formatting rule individually.
Is it safe to paste private or proprietary code into this tool?
Because the formatting happens locally in your browser and the code is not uploaded to any server, the snippet stays on your device. Once the page has loaded its scripts, it can even run offline.
Can I format JSON or TypeScript here too?
This tool is tuned for JavaScript syntax. For TypeScript, JSX, JSON, or other languages, use a dedicated formatter that loads the correct parser, otherwise valid code in those languages may be rejected as a syntax error.
Does pretty-printing add or remove comments from my code?
Pretty-printing preserves your comments and repositions them to fit the new formatting; it does not delete them. If you want comments removed, you would need a minifier or a separate tool, not a formatter.

Related tools