Developer Guides
How to Minify CSS, JavaScript and HTML Safely
What minifying removes, how much it saves next to gzip and Brotli, and how to test minified CSS, JavaScript and HTML before you deploy it.
Try it: CSS Minifier
Minifiers
Minifying removes the characters a browser or parser does not need, such as comments, indentation and line breaks, so files download faster. These minifiers cover web assets, data formats and source code. Paste your code, compare the before and after size, then copy or download the result. Nothing is uploaded.
Your code stays in the browser
Source code, configuration files and API payloads are minified on your own device and are never sent to a server.
Language-aware where it matters
JavaScript uses Terser, JSON is parsed first, and the XML, SVG, YAML, Java, C# and GraphQL minifiers respect strings, CDATA and comments.
See the saving at once
Most minifiers show the size before and after, with a copy button and a download, so you can judge whether the change is worth shipping.
Free, no sign-up
Minify as many files as you like without an account, and keep your original formatted source untouched.
The tools most visitors start with, and what each one is for.
Minify and compress JavaScript code to reduce file size.
Shrink a script with Terser by removing comments, shortening local variable names and simplifying code, while optionally keeping license comments.
Minify and compress CSS stylesheets to reduce file size.
Strip comments and whitespace from a stylesheet before you deploy it to a production site.
Minify and compress HTML code to reduce file size.
Collapse whitespace and remove comments from a static page or email template to reduce its weight.
Minify and compress JSON data to reduce file size.
Compact JSON for an API response or config file, with invalid input reported instead of producing broken output.
Minify and compress SVG files to reduce file size.
Remove the XML declaration, comments and indentation from SVG icons while leaving every shape and path untouched.
Minify XML data by removing whitespace and comments.
Squeeze a feed, sitemap or data export by removing whitespace between tags while keeping text and CDATA exactly as written.
Minify YAML configuration files by removing whitespace.
Strip comments and blank lines from a YAML config while keeping the indentation that defines its structure.
Minify GraphQL code to reduce bandwidth usage.
Trim comments, commas and whitespace from a query or schema to send a smaller request.
Format and beautify GraphQL queries with proper indentation.
Reformat a one-line or messy GraphQL query or schema with consistent indentation so it is readable again.
Format and beautify Markdown text with proper headings, lists, and code blocks.
Tidy Markdown headings, list markers, numbering and tables so a document renders consistently everywhere.
Short explainers that show how the maths or the file format works, and which tool to reach for next.
Developer Guides
What minifying removes, how much it saves next to gzip and Brotli, and how to test minified CSS, JavaScript and HTML before you deploy it.
Try it: CSS Minifier
Image Guides
A practical process for shrinking website images: right dimensions, right format, sensible quality, lazy loading and a checklist to verify the result.
Try it: Image Compressor
Each group explains what its tools are for, so you can find the right one without scrolling a long list.
The files every page load downloads: stylesheets, scripts, HTML and SVG graphics. Minifying these is the most common way to cut page weight, and it is best done on a copy while you keep the readable source.
Compact JSON, XML, YAML and GraphQL for APIs, feeds and config files. JSON is parsed first, XML keeps text and CDATA intact, and YAML keeps indentation because its structure depends on it.
Strip comments and formatting whitespace from Java and C# while leaving strings intact, or use the general Code Minifier to trim whitespace from PHP, Ruby or SQL, which does not parse those languages.
The opposite direction: add indentation and line breaks back so dense code or messy text is easy to read and edit. Covers GraphQL queries and schemas and Markdown documents.
Most minifiers let you copy the result to the clipboard or download it with the right extension, such as minified.js or minified.svg, ready to drop into a project.
The Java, C# and GraphQL minifiers leave string literals untouched, C# keeps preprocessor directives on their own lines, and XML keeps CDATA, so code does not change meaning.
The JavaScript Minifier can preserve /*! license */ comments and choose whether to shorten variable names, so legal notices survive minification.
Invalid JSON, unterminated strings and unclosed XML tags raise a clear message rather than quietly returning damaged code you might deploy.
Keep readable source as the original and use the GraphQL and Markdown formatters, or the formatters in Developer Tools, when you need to read minified text again.
Minifiers that change structure are the risky ones, so they are tested. Automated checks confirm that minified JSON and YAML load to the same data, that strings, CDATA sections, text inside SVG labels and C# preprocessor lines survive, and that invalid input raises an error. JavaScript is handled by Terser. The CSS, HTML and PHP, Ruby or SQL tools are simpler text-based minifiers, and the Code Minifier page says plainly that it does not parse syntax. Minified output should always be treated as a build artifact: keep the formatted source, and test the minified file where it will run.
It depends on how much of the file is comments and indentation. Heavily commented, well-indented code shrinks a lot and compact code only a little. Servers usually also compress text with gzip or Brotli, so the saving over the wire is smaller than the before and after figure shown.
It should not. Terser keeps JavaScript behavior the same, JSON is parsed and rewritten with identical values, and XML text is preserved. The CSS, HTML and PHP, Ruby or SQL options work on text rather than a parsed syntax tree, so review their output and test before you deploy.
In YAML, indentation defines structure, so collapsing lines would change or break the data. The YAML Minifier removes comments, blank lines and trailing spaces but keeps indentation, block scalars and quoted strings. Automated tests check that the result loads to the same data as the original.
It is useful for a one-off script or a quick check, using the same Terser engine that many build tools use. A bundler also combines files, removes unused exports and can write source maps. This tool minifies the code you paste and does not create a source map.
Only with care. It trims each line and joins them without parsing the language, so a line comment (// in PHP, # in Ruby, -- in SQL) can swallow the code after it. Remove comments first and run the result before using it. Python is excluded because indentation carries meaning.
You can restore indentation and line breaks with a formatter, but comments and original variable names are gone for good. Keep your readable source as the master copy and deploy the minified copy. The GraphQL Formatter here, and the CSS, HTML, JavaScript, JSON, SQL, XML and YAML formatters in Developer Tools, can make minified text readable again.
It depends on the tool. The JavaScript Minifier keeps /*! */, @license and @preserve comments by default, and the XML and SVG minifiers have a remove comments option. The CSS Minifier keeps /*! */ comments by default and removes the rest, and the HTML Minifier keeps conditional comments, so check the output if your license requires a notice.
Includes JSON Formatter, JSON Validator, JWT Decoder and more.
33 tools →
Includes HTML Validator, JSON Schema Validator, CSS Validator and more.
15 tools →
Includes Meta Title Generator, Meta Description Generator, Schema Markup Generator and more.
20 tools →
Includes Word Counter, Character Counter, Case Converter and more.
23 tools →
Looking for something that is not here? Tell us which tool you need, or browse all tools.