Esta página aún no está traducida al español, así que la mostramos en inglés.

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.

Actualizado el
 
Formatted JavaScript
 

Tus datos nunca salen de tu ordenador. Todo se procesa localmente en tu navegador.

Cómo usar: 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.

También se busca como: js beautifier, javascript beautifier, js formatter, unminify js, pretty print javascript, deobfuscate javascript, js minifier, minify javascript.

Herramientas que combinan con: 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.
  • Probador de expresiones regulares — Escribe un patrón y observa cómo se resaltan las coincidencias en tiempo real en tu texto de prueba.

Preguntas frecuentes

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.
¿Puedo instalar JavaScript Formatter como aplicación web y utilizarla sin conexión?
Sí. JavaScript Formatter es una aplicación web instalable (PWA): se instala desde el navegador, no se descarga desde una tienda de aplicaciones. Haz clic en «Instalar aplicación» en la parte superior de esta página en Chrome o Edge (Windows, macOS, Linux, ChromeOS) o, en Android, utiliza «Compartir» → «Añadir a la pantalla de inicio» en iPhone y iPad, o «Archivo» → «Añadir al Dock» en Safari 17+ en un Mac. A continuación, se abrirá en su propia ventana con su propio icono y, como se ejecuta íntegramente en tu navegador, seguirá funcionando sin conexión. Firefox en el ordenador de sobremesa no permite instalar aplicaciones web. Cómo funciona la instalación.

Herramientas relacionadas