Code Minify & Prettify

Input Code

Output Code

Format Options

Choose a language, paste your code, then click Prettify to beautify it or Minify to compress whitespace. Everything runs locally in your browser.

How to Use This Code Minifier & Prettifier

Minified JSON from an API response looks like one unreadable line. Pretty-printed CSS from a theme export balloons your deploy size. You need both directions—beautify to debug, minify to ship—and bouncing between desktop apps for a thirty-second fix wastes time. This formatter runs in your browser: paste code, pick a language, click Prettify or Minify, and copy the result.

Supported formats are JSON, JavaScript, CSS, HTML, and XML. JSON uses strict parsing so invalid syntax surfaces immediately. Web languages use safe whitespace and comment handling tuned for typical snippets, config files, and page templates—not full production build pipelines.

  • Paste code into Input Code. API payloads, stylesheet blocks, inline scripts, and markup fragments all work.
  • Select the language that matches your input—JSON for data files, JavaScript for scripts, CSS for stylesheets, HTML for page markup, XML for feeds and config.
  • Set prettify indent to 2 spaces, 4 spaces, or tabs. Indent applies when you click Prettify; minify always removes unnecessary whitespace.
  • Click Prettify to expand code with readable line breaks and indentation, or Minify to compress it for production or smaller transfers.
  • Copy, download, or Use as Input to chain operations—prettify messy code, edit it, then minify the cleaned version without re-pasting.

Nothing uploads to a server. Formatting happens locally in JavaScript, which keeps proprietary configs, API keys in JSON fixtures, and internal templates off third-party logs.

Code Formatter Workflows and Practical Applications

JSON prettify is the everyday fix: expand a one-line API response to find a missing comma, inspect nested keys before debugging a fetch handler, or prepare sample data for documentation. JSON minify strips whitespace for environment files, compact test fixtures, and curl-friendly payloads.

CSS minify shrinks stylesheet snippets before embedding in HTML email or a single-page prototype. CSS prettify unpacks minified theme CSS so you can read selectors and cascade order when overriding vendor styles.

HTML and XML prettify help when comparing template diffs, reviewing sitemap chunks, or cleaning exported CMS markup. Minify collapses inter-tag whitespace for lighter static fragments—useful for embed codes and partials where bytes matter.

JavaScript prettify makes obfuscated or single-line scripts readable for review. JavaScript minify removes comments and extra spaces from hand-written snippets—pair with caution on complex ES modules; full build tools like Webpack or esbuild remain the choice for large apps.

After formatting text blocks, continue cleanup with our Sort a List or Duplicate Line Remover. For character counts on output, use the Character Counter. For encoding binary-safe strings, try Base64 Encode / Decode.

Frequently Asked Questions

Which languages does this tool support?

JSON, JavaScript, CSS, HTML, and XML. Select the matching language before formatting so the correct rules apply to comments, tags, and syntax.

What is the difference between minify and prettify?

Prettify adds indentation and line breaks for readability. Minify removes unnecessary whitespace and comments to reduce file size. Use prettify to debug; use minify to compress code for production or transfer.

Will JavaScript minify break my code?

This tool uses conservative whitespace and comment removal that respects strings and template literals. It works well for typical snippets and scripts. For large bundled applications, use a dedicated build tool like Terser or esbuild.

Why does JSON formatting show an error?

JSON must be valid before formatting—trailing commas, single quotes, and unquoted keys cause parse errors. Fix the syntax or switch to JavaScript mode if the input is actually JS object literal syntax.

Is my code sent to a server?

No. Minify and prettify run entirely in your browser. Your code stays on your device unless you copy or download it yourself.