JS/CSS Minifier
FreeShrinks JavaScript or CSS by removing whitespace and comments, with optional variable name mangling for JavaScript, and before/after size stats.
Runs entirely in your browser. Your code is never uploaded anywhere.
What this tool does
Paste readable JavaScript or CSS and this tool shrinks it by removing whitespace, comments, and (for JavaScript, optionally) shortening local variable names, producing a smaller file with identical behavior.
How It Works
The tool parses your code into an abstract syntax tree using the open-source terser engine for JavaScript and clean-css for CSS, then re-generates the most compact equivalent source from that tree: dropping comments and unnecessary whitespace, shortening numeric and color values where safe, and, for JavaScript with mangling enabled, renaming local-scope identifiers to the shortest available names. Because the transformation works on the parsed structure rather than raw text, the resulting code behaves identically to the original.
Problems it solves
- Reducing JavaScript or CSS file size to speed up page load, especially before a manual deploy without a build pipeline.
- Quickly producing a production-ready bundle from a single script or stylesheet without setting up a full build tool.
- Seeing exactly how much smaller a file becomes, with an exact before/after size comparison.
Frequently asked questions
›Does this tool also format or beautify code?
No, this tool only minifies (shrinks) code by removing whitespace and comments. If you need readable, properly indented code instead, use a dedicated formatter tool.
›What does "mangle" mean for JavaScript?
Mangling renames local variables and function parameters to short names like "a" or "b" wherever it is safe to do so, which saves additional bytes beyond just removing whitespace. It never renames globally accessible names, so it does not break code that relies on specific global identifiers.
›Is minified code safe to use in production?
Yes, minification only changes whitespace, comments, and (optionally) local variable names. The logic and behavior of the code are preserved exactly, which is why minified JavaScript and CSS are standard practice on production websites.
›Why did minification fail with an error?
Minifiers need valid, parseable JavaScript or CSS. If your input has a syntax error, the minifier cannot build a correct internal representation of it. Check the code in a linter or browser console to find the exact issue, fix it, and try again.
›Should I keep an unminified copy of my code?
Yes. Always keep your original, readable source code as the version you edit and maintain, and generate the minified version as a build step. Treat minified output as a disposable artifact, not a file to hand-edit.
Related Tools
Text
JS/CSS Formatter
Reformats minified or inconsistently indented JavaScript or CSS into readable, properly indented code, with adjustable indent style and before/after size stats.
FreeText
HTML Validator
Check HTML for unclosed tags, duplicate IDs, deprecated elements, and other common well-defined issues, verified with its own tag-matching parser, not a full W3C conformance validator.
FreeText
IPv4 To IPv6 Converter
Generates IPv4-mapped, IPv4-compatible, 6to4, and NAT64 IPv6 representations of an IPv4 address, and extracts the IPv4 address back out of any of those IPv6 forms.
FreeText
JSON Encoder
Encodes plain text into a valid JSON string literal (escaping quotes, backslashes, and line breaks) and decodes it back, with an escape-character breakdown.
FreeText
JSON Formatter
Validates and pretty-prints or minifies a full JSON document, with adjustable indent, optional key sorting, and exact line/column error reporting.
FreeText
JWT Decoder
Decodes a JWT header and payload into readable JSON, converts timestamp claims to human-readable dates, flags expired tokens, and can verify an HS256 signature with a secret you provide.
FreeText
llms.txt Generator
Generates a llms.txt file following the llmstxt.org specification from a title, summary, and sections of links, with Optional-section grouping and a live preview.
FreeText
Markdown Previewer
Renders Markdown as live, sanitized HTML side by side with the source, with a toggle to view and copy the generated HTML.
Comments (0)
Found this tool useful? Leave a comment, share a tip, or tell us how we can make it better.
No comments yet. Be the first to share your thoughts!