Code Minifier — HTML, CSS & JS

Minify JavaScript (Terser), CSS and HTML online to make websites load faster. Free.

50 free uses every 24 hoursUnlimited with Pro →

Private by design — your data stays on your deviceEverything runs right here in your browser. What you type is not sent to our server and is not stored.
  • Runs in your browser
  • Not stored
  • No sign-up

This code minifier shrinks JavaScript, CSS and HTML by removing spaces, comments and other characters the browser does not need. It is built for web developers, site owners and anyone who wants smaller files and faster pages. It is free to use, and your code is processed in your browser, so nothing is uploaded.

How to use the code minifier

  1. Choose the language: JavaScript, CSS or HTML.
  2. Paste your code into the input box.
  3. Click Minify.
  4. Check the size saving shown, then copy the result.
How to use the HTML / CSS / JS Minifier on OneHubTools: 4 steps with a real screenshot of the tool
How to use the HTML / CSS / JS Minifier, step by step.

This tool pairs well with the HTML / CSS / JS Beautifier. If you do this kind of job often, the JSON Formatter & Validator and the JSON to XML / XML to JSON can save you time too.

Paste one language at a time. A CSS block pasted into the JavaScript option will not work, because each language is handled by its own rules.

What does minifying code actually do?

Minifying removes everything a browser ignores. That means line breaks, indentation, extra spaces and comments. The code behaves the same, but the file is smaller, so it downloads faster.

JavaScript is minified with Terser, a widely used minifier. Because of that, variable names in your script may come out shorter than what you wrote. That is normal and part of why the file shrinks.

Result from the HTML / CSS / JS Minifier on OneHubTools
What the HTML / CSS / JS Minifier gives you.

What is a JS, CSS and HTML minifier good for?

  • Faster page loads. Smaller scripts and stylesheets mean less to download before a page shows up.
  • Cleaning up before launch. Run your final CSS and JavaScript through the tool before you upload them to your site.
  • Small sites and landing pages. If you do not use a build tool, you can minify a file by hand in a minute.
  • Inline snippets. Tracking code, widgets and email-friendly HTML are easier to embed when they are compact.
  • Quick size checks. The size saving shown after you click Minify tells you how much a file really weighs in extra characters.

Tips for getting the best results

  • Keep your original file. Minified code is hard to read and edit. Save the readable version and only publish the minified copy.
  • Test after minifying. Load the page and click through it. This takes a minute and catches most problems early.
  • Fix errors first. A missing bracket or unclosed tag in your input is easier to find before minifying than after.
  • Do not minify twice. Files that already end in .min.js or .min.css are minified. Running them again gains you little.
  • Watch your comments. Comments are removed. If a comment holds licence or author information you must keep, add it back to the published file.
  • Name files clearly. Something like style.min.css next to style.css makes it obvious which one is which.

Why does my minified code not work?

Most of the time the problem was already in the source. Minifying makes small mistakes more visible.

  • JavaScript errors. A syntax error in your original script can stop Terser from producing output. Check the code runs before you paste it in.
  • Code that depends on exact names. If other scripts or HTML attributes refer to a function by its original name, shortened names can break the link. Compare the result with your page.
  • HTML spacing. Removing whitespace between inline elements can change how text looks. Preview the page after minifying HTML.
  • Wrong language selected. If the output looks odd or empty, check you chose the right option before clicking Minify.

Which language gets which kind of cleanup?

LanguageWhat the minifier removesWhat to check afterwards
JavaScript (Terser)Spaces, comments, unneeded characters; names may be shortenedPage features and console errors
CSSSpaces, line breaks, commentsLayout and styling on key pages
HTMLSpaces, line breaks, commentsText spacing and page structure

Can you turn minified code back into readable code?

Partly. The Code Beautifier can add line breaks and indentation again so you can read the code. It cannot restore shortened variable names or deleted comments, so keep your original source safe.

Limits and specs

PriceFree
Free use50 uses every 24 hours — shared with 178 other tools in the “Basic tools” group
Where it runsIn your browser
Sign-upNot needed
Muhammad Shahwaiz Gillani
Maintained and reviewed by Muhammad Shahwaiz GillaniSoftware engineer and founder of OneHubTools · Last reviewed

How we checked it: We tested it in Chrome with real code and data, including edge cases such as empty input and very long values.

Where the facts come from

According to MDN Web Docs, the File API lets web pages read files you choose on your own device without uploading them, and all major browsers have supported it for more than 10 years.

Spotted a mistake or the tool did not work for you? Tell us and we will fix it.

Rate this tool

Ratings come only from signed-in users, so every rating is verified.

Only signed-in users can rate tools, so every rating shows a ✔ Verified badge.Sign in to rate

Frequently asked questions

What is a code minifier?

A code minifier is a tool that removes spaces, comments and unnecessary characters from code to make the file smaller. The code still does the same job, but it loads faster in the browser.

How do I minify JavaScript online?

Choose JavaScript, paste your script into the box and click Minify. The tool uses Terser, then shows the size saving so you can copy the result.

Can I minify CSS and HTML as well?

Yes, this tool handles JavaScript, CSS and HTML. Pick the language first, then paste your code and click Minify.

Is my code uploaded anywhere?

No, your code is processed in your browser and is not uploaded. The tool is free to use.

Can minified code be reversed?

Only partly. Use the Code Beautifier to make it readable again, but names stay short and removed comments do not return.

Will minifying change how my website works?

It should not, because only characters the browser ignores are removed. Still, test your pages after minifying, especially JavaScript and HTML.