JSON Formatter
Pretty-print messy or minified JSON with 2-space indents.
Shrink a script in your browser by stripping comments and collapsing whitespace. It is a naive regex minifier: fast, but it can break real code.
Your browser is preparing the tool. It runs 100% locally.
Paste JavaScript and the tool removes comments and the whitespace around operators and punctuation, collapsing the script toward one line. Be warned: it is a naive regex minifier, not a real one. It does not understand strings, template literals or regular expressions, so it can break working code in those cases. Use it for trivial snippets and reach for a proper minifier like Terser for anything real. It runs in your browser; nothing is uploaded.
This tool makes a quick attempt at shrinking JavaScript by deleting comments and squeezing out the whitespace that the engine does not need: the indentation and the spaces around operators and punctuation. For simple, self-contained snippets the output is smaller code that still runs.
It is a fast, no-build way to compress a small script. But because it works by pattern-matching rather than understanding the language, it has real caveats. Treat it as a rough whitespace squeezer rather than a production minifier.
The tool runs a sequence of regular expressions: it removes block comments and line comments, strips the indentation at the start of each line, removes the whitespace on either side of operators and punctuation, and finally joins the lines together. There is a small guard so that the slashes in a URL like a https address are not mistaken for a comment.
It never parses the code. It does not know where a string starts or ends, what is inside a template literal, or where a regular expression sits. It reacts to characters only. That keeps it fast and dependency-free, and it is also why it can corrupt code that a real, parser-based minifier would handle safely.
• remove block and line comments (with a guard for a URL)
• strip leading indentation
• remove whitespace around operators and punctuation
• join the lines into one
it never parses, so it cannot see strings, templates or regexBefore: function add(a, b) { return a + b; }
After: function add(a,b){return a+b;}That simple case works. But a line comment marker inside a string gets treated as a comment and truncates the string; a multi-line template literal has its indentation collapsed, changing the text; and removing spaces around the divide sign can corrupt a regular expression. A parser-based minifier avoids all of these.
Your code never leaves your device. It is minified in your browser with no network request, so nothing is uploaded.
Because the work is local, you can run it on proprietary scripts without them being stored or sent anywhere, though real code deserves a proper minifier.
Nothing carries over between visits. Close the tab and the input and output are gone.
For a small, self-contained function the output is correct and smaller. On real code this naive regex approach can break things, so keep it for trivial snippets you can check by eye afterwards.
It does not understand strings. A line-comment marker inside a string is treated as the start of a comment, so the rest of that line, including the closing quote, is deleted and the code breaks. A parser knows the marker is inside a string and leaves it alone.
Template literals and regular expressions are at risk too. The indentation inside a multi-line template literal is collapsed, changing the text it produces, and removing the spaces around the divide sign can mangle a regular expression. The tool cannot tell these apart from ordinary code.
It does not rename variables or do any real optimisation, so even when it works it compresses less than a proper minifier. And by joining lines it can run into automatic-semicolon-insertion issues. For anything beyond a trivial snippet, use Terser or esbuild.
Compress a few lines of simple JavaScript you can check by eye.
See roughly how much whitespace a small script carries.
Watch comments and spacing disappear from simple code.
Shrink a small, string-free function for a quick paste.
For anything real, use a parser-based minifier such as Terser or esbuild, which preserves strings, template literals and regex, handles semicolons safely, and can rename variables for far better compression. This tool is only for trivial snippets you will verify by hand.
Shrinks by stripping comments and removing whitespace around operators with regular expressions. This naive approach can corrupt strings, template literals and regex patterns, so it is for trivial snippets only.
Pretty-print messy or minified JSON with 2-space indents.
Paste JSON and find out whether it parses.
Standard Base64 for any text, emoji included.
MD5, SHA-1 and the SHA-2 hashes of any text, as you type.
Up to 500 random version 4 UUIDs at once.
Strips comments and whitespace to put a stylesheet on one line.
Paste, run and copy. The code stays in your browser and you don't need an account.