Cette page n’est pas encore traduite en français : elle s’affiche en anglais.

JavaScript Formatter & Beautifier

Unminify and pretty-print JavaScript, JSON or JSX with your preferred indentation and brace style — or strip whitespace and comments with a verified minifier.

Mis à jour le
 
Formatted JavaScript
 

Vos données ne quittent jamais votre ordinateur. Tout le traitement se fait localement dans votre navigateur.

Comment utiliser : JavaScript Formatter

  1. Paste JavaScript (or JSON/JSX) into Input JavaScript, drop a .js file, or click Sample.
  2. Choose the indentation, an optional wrap width and your brace style. The output updates instantly.
  3. Copy or download the result. Use Minify mode to remove comments and whitespace from a small script.

What is a JavaScript formatter?

A JavaScript formatter (or beautifier) re-indents code and puts statements, object properties and blocks on separate lines. Its most common job is to unminify production bundles so you can read them while debugging, but it is equally handy for tidying a snippet from Stack Overflow, a bookmarklet, or code pasted from a chat. This tool uses js-beautify, which understands modern syntax: arrow functions, classes, template literals, async/await, optional chaining, ES modules and JSX.

Brace styles

OptionResult
Same line (K&R / “1TBS”)if (ok) { — the convention in most JavaScript style guides and Prettier.
Same line, keep inlineAs above, but short blocks such as { a: 1 } stay on one line.
Next line (Allman)Opening braces on their own line, common in C# codebases.
else on new line} and else on separate lines (Stroustrup-like).

Beautifying is not deobfuscating

Minifiers such as Terser or esbuild rename local variables to single letters (function(e,t){…}). Formatting restores the layout but cannot bring back the original names or comments — that information is gone. If the site publishes source maps (//# sourceMappingURL=), your browser’s DevTools can show the original sources instead. Code that has been deliberately obfuscated (string arrays, eval packing) stays hard to read even when formatted.

About the minifier

The Minify mode is a safe whitespace-and-comment minifier, not a full compressor. It tokenizes your code properly (strings, template literals, regular expression literals) and removes comments and spaces, but keeps a line break wherever removing it could change automatic semicolon insertion — for example after return or before ++. Two safety checks run on every result: the token stream must be identical to the input, and the output must still parse. Expect 20–40% savings; for production bundles, a build tool such as Terser or esbuild also renames variables and removes dead code for much bigger wins.

Common issues

  • “Doesn’t parse as plain JavaScript” — shown for TypeScript, JSX or a real syntax error. Formatting still works; minify requires valid JavaScript.
  • JSON formats fine here, but the JSON Formatter also validates it and points to the exact error.
  • Want to compare a file before and after a change? Paste both versions into the Diff Checker.

Aussi recherché comme : js beautifier, javascript beautifier, js formatter, unminify js, pretty print javascript, deobfuscate javascript, js minifier, minify javascript.

Outils complémentaires : JavaScript Formatter

  • Code to Image — Paste a snippet and get a polished code screenshot in seconds: syntax highlighting for JavaScript, TypeScript, Python, CSS, HTML, JSON, SQL, Bash, Go and PHP, a choice of themes, a window frame with a file name, a gradient or transparent background, padding and line numbers.
  • HTML Formatter — Paste minified or messy markup and get clean, consistently indented HTML — including embedded <style> and <script> blocks.
  • CSS Formatter — Turn a minified stylesheet into readable CSS with one property per line and properly nested @media blocks.
  • Testeur d’expressions régulières — Saisissez un modèle et observez les correspondances s'afficher en temps réel dans votre texte de test.

Questions fréquentes

Can this unminify JavaScript from a website?
Yes. Paste the contents of a .min.js file and it will be laid out readably. Variable names shortened by the minifier (like e, t, n) cannot be restored, and comments are gone for good.
Does it support TypeScript and JSX?
JSX is supported. Most TypeScript formats acceptably because the syntax is close to JavaScript, but type-heavy code (generics, decorators) is better handled by Prettier. The minifier only accepts plain JavaScript.
Is the minifier safe to use on my code?
It only removes comments and whitespace and keeps line breaks where automatic semicolon insertion could depend on them. Every result is verified to have the same tokens as the input and to still parse; if a check fails, nothing is output. Still, test before deploying.
Why is my code not minified as much as with Terser?
Terser and esbuild also rename variables, inline constants and remove unreachable code. This tool deliberately doesn’t rewrite code so the output stays recognizable — use a bundler for production builds.
Is my code uploaded?
No. Formatting and minification happen locally in your browser; your code never leaves your device.
Puis-je installer JavaScript Formatter en tant qu’application web et l’utiliser hors ligne ?
Oui. JavaScript Formatter est une application web installable (PWA) : elle s’installe depuis votre navigateur, sans passer par une boutique d’applications. Cliquez sur « Installer l’application » en haut de cette page dans Chrome ou Edge (Windows, macOS, Linux, ChromeOS) ; sur Android, utilisez « Partager » → « Ajouter à l’écran d’accueil » sur iPhone et iPad ; ou « Fichier » → « Ajouter au Dock » dans Safari 17+ sur Mac. L’application s’ouvre alors dans sa propre fenêtre avec sa propre icône, et comme elle s’exécute entièrement dans votre navigateur, elle continue de fonctionner hors ligne. Firefox sur ordinateur de bureau ne permet pas d’installer d’applications web. Comment fonctionne l’installation.

Outils similaires