How to Minify & Beautify JS, CSS & HTML Safely (Without Breaking URLs)
By Rohit Kumar · Updated 2026-11-28 · 4 min read
Quickly minifying an inline embed snippet or beautifying a compressed stylesheet should not silently corrupt your JavaScript. Surprisingly, many simple regex minifiers strip `//.*` across the whole file—accidentally deleting everything after `https://` inside a string literal! Tooltable’s upgraded Code Formatter uses quote-aware parsing so URLs and strings stay 100% intact.
Free Browser Tools Used in This Guide
- Code Beautifier & Minifier (HTML/CSS/JS) — Format or minify HTML, CSS, and JavaScript locally with exact byte savings.
- JSON Formatter, Validator & Converter — Prettify, minify, validate JSON with error diagnostics, and export to CSV or YAML.
- XML Formatter & Validator — Pretty-print, minify, and validate XML documents using the native browser DOMParser.
The Infamous `https://` Minifier Bug Explained
When a naive minifier runs `.replace(/\/\/.*$/gm, "")` on `const api = "https://tooltable.info/api";`, it mistakes `//tooltable.info/api";` for a JavaScript line comment and deletes the closing quote and semicolon—breaking the entire script.
Tooltable’s quote-aware scanner tracks single quotes, double quotes, template literals, and backslash escapes character by character, stripping only real comments outside string literals.
| Language | Beautify / Pretty-Print | Safe Minify |
|---|---|---|
| JavaScript / TypeScript | Brace-aware 2-space indentation | Quote-safe comment & whitespace removal |
| CSS | Clean selector blocks & properties | Strips /* comments */ & extra spaces |
| HTML | Readable tag hierarchy indentation | Compacts inter-tag whitespace safely |
Step-by-Step: Clean or Compact Code Snippets Locally
Open Tooltable’s Code Formatter, select JavaScript, CSS, or HTML, and paste your snippet.
- Click Beautify to expand minified third-party snippets into readable, indented blocks for auditing.
- Click Minify to trim bytes for bookmarklets, email templates, or lightweight inline scripts.
- Copy the verified output immediately with zero server transmission.
Pro Tip: For full production React or TypeScript bundles, rely on Vite/esbuild—use this browser tool for fast ad-hoc snippets, debugging minified payloads, and inline widget code.
Zero Source-Code Exposure
Proprietary front-end code, unreleased marketing embeds, and internal CSS design tokens stay exclusively inside your browser tab with zero analytics or logging. Because Tooltable tracks string delimiters, template literals, and block comments character by character, you can minify inline scripts containing `https://` API endpoints, regex patterns, or SVG data URIs with full confidence that your code still parses cleanly in production browsers. Once formatted or minified, test the result immediately without ever sending proprietary source code across external servers.
Developers auditing third-party widgets or debugging production bundle snippets can also compare minified before-and-after byte sizes instantly, making it simple to trim unnecessary CSS rules and comments from email templates or CMS header scripts.
Frequently Asked Questions
Does minifying JavaScript keep https:// URLs inside strings safe?
Yes. Tooltable’s parser explicitly tracks string and template literal boundaries so `//` inside URLs is never treated as a comment.
Can I beautify minified CSS from a browser DevTools inspection?
Yes. Select CSS mode and click Beautify to expand one-line stylesheets into clean multi-line rules.
Does this tool upload my code?
No. Formatting and minification run 100% locally in your browser.