Minify or beautify JavaScript, TypeScript, CSS, HTML, JSON, XML and SQL as you type, without touching strings or licences, and see the bytes saved.
Initializing in your browser…
Format, validate and minify JSON, JSONC or JSON5 as you paste, with exact numbers, precise error locations, a tree view, JSONPath queries and schema checks.
Format, minify or convert XML to JSON as you type, with line-and-column error checks, a tree view and XPath queries that handle namespaces.
Format and validate YAML or convert between YAML and JSON as you type, keeping comments, anchors and exact numbers, with YAML 1.1 and 1.2 support.
You need to paste a small analytics snippet into a site's header field and want it as short as possible without breaking it.
JavaScript, 212 bytes
/*! analytics v2 | MIT */
// Track a page view
function track(page) {
const url = "https://example.com/collect?p=" + page; // not a comment
console.log("tracking", page)
return fetch(url)
}
let retries = 3Minified, Aggressive level, 127 bytes (40.1% smaller)
/*! analytics v2 | MIT */
function track(page){const url="https://example.com/collect?p="+page;return fetch(url)}
let retries=3Both ordinary comments are gone, but the /*! licence comment stays. The // inside the URL string is part of the string, so it survives. The console.log call is a whole statement, so the Aggressive level removes it. Two line breaks remain. JavaScript can treat a line break as the end of a statement, so where a statement ends without a semicolon the break is kept rather than risk changing the program, and a note under the result says how many were kept.
Paste JavaScript, TypeScript, CSS, HTML, JSON, XML or SQL to minify it for production or beautify it for reading. The result updates as you type and shows exactly how many bytes you saved, ready to copy or download.
Minifying removes everything a computer does not need, such as comments, indentation and line breaks, so files download faster. Beautifying does the opposite and lays compressed code out so a person can read it. This tool does both for seven languages, in your browser, and it is careful about the cases that trip up simple find-and-replace minifiers.
It reads the code before changing it. Each language is split into proper tokens first, so the tool knows the difference between a comment and two slashes inside a string, a URL in a CSS url() or a regular expression in JavaScript. Text inside strings, template literals, regular expressions and HTML <pre> blocks is never touched. In JavaScript, a line break is kept where removing it would change the meaning of the program, which happens when a statement ends without a semicolon; the tool tells you how many it kept and why. Licence comments that start with /*! or contain @license are kept, as most licences require.
Three levels. Safe removes comments and collapses whitespace, which is right for almost every file. Aggressive also removes console calls that stand as whole statements (a console call inside an expression is kept, since removing it would break the expression) and drops redundant semicolons before closing braces. Maximum also removes HTML conditional comments such as <!--[if IE]>. Each switch can be changed individually under More options. Variables are not renamed, because doing that safely requires analysing scopes across the whole program; use a build tool such as Terser or esbuild if you need that last step.
Beautify with your style. Beautify mode indents with 2 spaces, 4 spaces or tabs, puts one statement or declaration per line, and works for minified JSON, XML and SQL as well as code. For SQL, choose the dialect so quoted identifiers and backslash escapes are read correctly; MySQL treats a backslash inside a string as an escape and the others do not.
Honest numbers. Sizes are measured in bytes of UTF-8, the same as a file on disk, so the percentage saved matches the file you download. Minified output is often 20 to 60 percent smaller before compression; gzip or Brotli on your server then shrinks it further. Nothing is uploaded, so you can safely minify private source code.
Minify a snippet, widget or bookmarklet before pasting it into a CMS, tag manager or HTML page.
Beautify a compressed stylesheet, script or JSON response to debug it or understand what a third-party file does.
Minify the CSS you inline in a page head so it adds as few bytes as possible to every request.
Lay out a one-line SQL query or XML payload from a log so you can read and edit it, then minify it again if needed.
A 212-byte JavaScript function with a /*! MIT */ licence comment, two ordinary comments and a console.log minifies at the Aggressive level to 127 bytes. The licence stays, the URL containing // stays intact, and two line breaks are kept because the statements had no semicolons.
A 69-byte rule with a comment and a url("a//b.png") value becomes .btn{color:#fff;background:url("a//b.png")} at 43 bytes. The double slash inside the URL is not mistaken for a comment.
{"a":1,"b":[1,2]} in Beautify mode with 2 spaces becomes a seven-line document with each array item on its own line.
Yes, that is what it is for. The tool only removes comments and whitespace that do not affect behaviour, keeps line breaks that JavaScript relies on, and never changes strings or regular expressions. As with any build step, run your tests on the minified file before deploying.
JavaScript inserts semicolons automatically at some line breaks. If a statement ends without a semicolon, joining it to the next line can change what the code does, so the tool keeps that line break and reports it. Add semicolons to your source if you want a single line.
No. Renaming variables safely requires understanding every scope in the program, which this tool does not attempt. For maximum compression of a large application, use a bundler with Terser or esbuild; for snippets and stylesheets, comment and whitespace removal gives most of the saving.
Safe removes comments and extra whitespace. Aggressive also removes console calls that are complete statements and the last semicolon before a closing brace. Maximum also removes HTML conditional comments. You can adjust each option separately under More options.
Databases quote names and escape strings differently. MySQL uses backticks and treats a backslash in a string as an escape; PostgreSQL and SQL Server do not. Choosing the right dialect makes sure strings and identifiers are recognised correctly, so nothing inside them is altered.
No. All processing happens in your browser, so private or proprietary code never leaves your computer.
Your text is processed locally in the browser. Nothing you paste or open is transmitted or logged.