JavaScript formatter and minifier — pretty-print JS/TS, compress for smaller bundles

Use this free JavaScript formatter online to beautify minified or one-line code, read vendor bundles during incident response, and align snippets before code review. Switch to JavaScript minification when you want a quick sense of how much smaller a function or module might look after Terser-style compression—without uploading source to a third party. Formatting uses Prettier semantics for TypeScript and modern JS. Pair it with our CSS formatter & minifier and HTML formatter & minifier when you tune full static pages or embedded widgets.

Ready — use Format for JS/TS pretty-print or Minify for smaller JavaScript output.

Format accepts JavaScript and TypeScript (including many modern syntax features). Minify targets executable JavaScript—strip types or build first if Terser reports parse errors.

Why format or minify JavaScript?

Readable code speeds up debugging: a JS beautifier reveals structure—blocks, async flows, and error paths—that disappear in production bundles. A JavaScript compressor trims noise humans no longer need and can shrink gzip- or Brotli-compressed payloads slightly, which matters on large third-party scripts or legacy pages. Neither replaces your CI pipeline, but both help support, education, and quick experiments.

When you work with APIs and config side by side, keep JSON legible with the JSON formatter & validator after you adjust fetch payloads in your scripts.

How to use this JavaScript formatter (step by step)

  1. Paste JavaScript or TypeScript into the textarea—functions, modules, or a chunk from a stack trace. Click Load sample to try a compact async helper.
  2. Click Format to run Prettier: indentation, semicolons, and line breaks become consistent. Fix any parse error shown in red until the status line confirms success.
  3. Click Minify when you need smaller JavaScript. Terser removes comments, collapses whitespace, and may shorten local names. If you pasted raw TypeScript types, compile or strip them first—minify expects valid JS.
  4. Use Copy to move output into VS Code, a gist, or a ticket. For SQL-heavy dashboards rendered by your app, also try the SQL formatter.

Keywords teams search for

Engineers often look for an online JS prettifier, minify JavaScript for production, or a TypeScript formatter in the browser when they cannot install packages on a locked-down machine. This page supports those workflows without an account. For YAML-heavy pipelines, cross-check config with YAML to JSON after you edit deployment scripts.

Minify vs format: bundles, Core Web Vitals, and SEO

Minified JavaScript can reduce parse and download time on very large scripts, especially alongside CDN compression and HTTP caching. It does not fix slow frameworks or blocking tags by itself. Formatted JavaScript improves human readability for docs, training, and security review. For public sites, keep serving hashed, cached assets from your host and use this tool as a scratchpad.

If you inspect live pages, validate head markup with the meta tags extractor after you change scripts that touch SEO tags or structured data.

Security, privacy, and obfuscated code

Processing stays in your browser, which helps when scripts contain secrets, unreleased features, or customer data in string literals. Be cautious pasting untrusted obfuscated code: formatting does not sandbox execution. When you analyze suspicious patterns, combine this with the regex tester & debugger for extraction experiments in isolation.

Limitations vs Prettier CLI and your bundler

Your repository should still define Prettier, ESLint, and build targets so CI matches local editors. This page uses sensible defaults (two-space indent, trailing commas where safe) and does not read .prettierrc. Use it for ad-hoc snippets; use your toolchain for releases. For markup-heavy templates, the XML formatter may fit RSS, SVG, or SOAP payloads better than a JS-only view.

Related developer tools

Explore the full code and developer tools catalog. Highlights:

  • JSON Formatter & ValidatorFormat, validate, minify, and explore JSON in a collapsible tree—fix payloads before they hit production.
  • JSON to CSV ConverterTurn JSON arrays into downloadable CSV with automatic column detection for spreadsheets and BI tools.
  • JSON to YAML ConverterConvert JSON to readable YAML for configs and Kubernetes—copy or download the result.
  • CSV to JSON ConverterPaste or upload CSV and get structured JSON with header-aware typing for APIs and apps.
  • YAML to JSON ConverterParse YAML to valid JSON with clear errors—ideal for CI configs and cloud templates.
  • XML Formatter & ValidatorBeautify and validate XML with structure insight and actionable parse errors.
  • Regex Tester & DebuggerTest patterns live with highlights, capture groups, and flags—debug regex without leaving the browser.
  • SQL FormatterPretty-print SQL with indentation and keyword casing for readable queries and code review.
  • HTML Formatter & MinifierBeautify or minify HTML and compare raw markup with a quick rendered preview.
  • CSS Formatter & MinifierFormat messy stylesheets or minify CSS for faster loads—keep design tokens consistent.
  • HTML to Markdown ConverterConvert HTML snippets to Markdown for docs, CMS migrations, and README cleanup.
  • Markdown to HTML ConverterTurn Markdown into HTML with a live preview—handy for emails, blogs, and static pages.
  • Code Diff CheckerCompare two code blocks side by side with clear add/remove highlighting for reviews.
  • JWT DecoderDecode JWT header and payload and check expiry—signature verification not included, client-side safe.

Frequently asked questions

What does this JavaScript formatter and minifier do?
Format (beautify) uses Prettier’s Babel-based parser to pretty-print JavaScript and TypeScript with consistent indentation and line breaks. Minify uses Terser to remove whitespace and comments, shorten variable names where safe, and apply light compression so bundles are smaller. Both steps run entirely in your browser.
Is my code sent to your servers?
No. Prettier and Terser execute locally in your tab. Nothing is uploaded for formatting or minification unless you use another page that explicitly makes network requests.
Can I minify TypeScript or JSX as-is?
Minification expects JavaScript the engine can parse. Plain TypeScript types, interfaces, and some TS-only syntax will make Terser fail—use Format for TS/TSX, or compile to JavaScript first, then paste the output here to minify. JSX in .tsx-style snippets may need to be valid after your toolchain strips types.
How is this different from my editor’s Prettier or my bundler?
Your repo’s Prettier config, ESLint rules, and bundler (Vite, webpack, esbuild) are the source of truth for CI and production. This page is a fast scratchpad: paste a snippet from a stack trace, beautify obfuscated code for reading, or estimate minified size without touching package.json.
Will minify break my code?
Terser is widely used in production, but aggressive mangling can interact badly with eval, dynamic property access on minified names, or code that relies on Function.prototype.toString. Test minified output in your app. For libraries consumed by others, ship source maps and consider disabling mangle for public APIs.
Why does Format fail with a parse error?
Prettier needs syntactically valid JavaScript or TypeScript. A missing bracket, unfinished template literal, or pasted HTML instead of script will fail. Fix the syntax in your editor, or use our HTML formatter if you grabbed a full page by mistake.
Does this replace terser-webpack-plugin or Vite’s build.minify?
No. Use those tools for repeatable production builds, tree-shaking across modules, and integration with your framework. Use this utility for one-off inspection, demos, and quick before/after size checks on a single file or fragment.
Which related tools pair well with this one?
Format CSS with the CSS formatter and minifier, clean markup with the HTML formatter and minifier, validate JSON payloads with the JSON formatter and validator, and debug patterns with the regex tester—all linked from the code and developer tools section on the home page.