Skip to main content

Code Minifier (JSON / CSS)

Minify JSON or CSS in one place. The tool detects JSON by its braces and minifies accordingly; otherwise it minifies as CSS.

Reviewed for accuracy by the Math Ora X team Last updated

About this tool

Minify JSON or CSS in one place. The tool detects JSON by its braces and minifies accordingly; otherwise it minifies as CSS.

Example

Input: a { color: red; }

Output: a{color:red}

Privacy

This tool runs entirely in your browser. Your data is processed locally and never uploaded to a server.

How to use this tool

  1. Paste your JSON or CSS into the input box.
  2. Let the tool detect the format automatically from the braces or the CSS text.
  3. Review the minified result in the output area.
  4. Copy the compact code and use it in your project.

Step by step, what happens

  1. The tool reads the text you paste and checks whether it looks like JSON based on its braces.
  2. If it matches JSON, it removes whitespace and formatting characters that are not needed.
  3. If it does not look like JSON, it treats the input as CSS and removes comments and extra spaces.
  4. The cleaned result is shown immediately so you can copy it without running a separate build step.

Worked example

Here is a small CSS example that shows how the tool removes comments and extra spacing.

Input: /* main styles */ body { color: red; margin: 0; }

  1. The tool sees that the input is not wrapped like JSON, so it treats it as CSS.
  2. It removes the comment and trims the extra line breaks and spaces.
  3. It keeps the CSS rules and punctuation needed for valid CSS.

Output: body{color:red;margin:0;}

Tips and common mistakes

  • Make sure JSON input is valid before minifying, because the tool only compresses it and does not fix syntax errors.
  • If your CSS includes comments you want to keep, remove them first because minifying will strip them out.
  • Paste only the code you want to compress, since surrounding notes or labels can affect auto-detection.
  • Check the output after minifying if you use special CSS hacks or formatting that depends on whitespace.

Frequently asked questions

Which languages?

JSON and CSS, auto-detected.

Does it validate JSON?

Yes, invalid JSON is reported as an error.

Why minify?

To reduce file size for faster delivery.

Facebook Twitter WhatsApp