ForHosting KIT · Data & Files

Minify CSS

A stylesheet written for a human to maintain and a stylesheet served to a browser have different jobs, and most projects still ship one file trying to do both. This endpoint takes your readable CSS and returns the smallest equivalent, so the render-blocking request that loads it finishes faster.

● StableFree · in your browser
Use it from WebAPIEmailApp soonTelegram soon

Runs in your browser. Free, unlimited — your data never leaves this page.

Why stylesheet size still matters

CSS is render-blocking by default: a browser generally won't paint a page until it has downloaded and parsed the stylesheets that page depends on, which makes every unnecessary byte in that file a direct tax on time-to-first-paint. Source-formatted CSS — full of nested indentation, one selector per line, comments documenting a hack for an old browser — is exactly what a developer wants to read and exactly what a browser doesn't need. data.css_minify keeps the readable version in your source tree and only compacts the copy that actually gets served.

What the endpoint returns

Send POST /data/css-minify with the stylesheet source, and you get a task_id back while minification runs. The compacted CSS — whitespace collapsed, comments stripped, trailing semicolons and redundant units trimmed where it's safe to do so — arrives through a signed webhook call or waits behind a signed link valid for 24 hours.

Safe compaction, not aggressive rewriting

CSS minification has to respect the cascade: reordering or merging rules carelessly can change which declaration wins when two selectors conflict, and CSS's specificity and source-order rules have been part of the spec since the language's earliest versions on the web. A conservative minifier removes what's provably safe to remove — whitespace, comments, redundant zeros and units — without touching selector order or rule structure, which is the difference between a smaller file and a stylesheet that renders a page differently than before.

Fitting into a build pipeline

Teams that don't want to install and maintain a bundler's CSS plugin, or that generate stylesheets outside a typical JavaScript build chain — from a static site generator, a CMS theme, or a design system exported by a non-JS tool — can call this endpoint as their minification step instead. Because pricing is per request with no charge on failed jobs, and the task runs async, a build script can fire off every stylesheet in a project in parallel and collect the results by webhook, treating minification as one predictable line in the deploy process rather than a dependency to keep patched and configured.

Static site build without a JS bundler

A static site generator written outside the JavaScript ecosystem minifies its CSS output through the API instead of embedding a bundler-specific plugin.

CMS theme delivery

A content management system minifies theme stylesheets before serving them to visitors, cutting render-blocking payload size on every page load.

Design system export step

A design tool exports generated CSS and minifies it via the API before publishing the component library's stylesheet.

CI deploy pipeline

A CI pipeline minifies every CSS file changed in a release as a build step, keeping source files fully formatted for code review.

How do I minify CSS with the API?

POST your stylesheet to /data/css-minify, keep the returned task_id, and collect the minified CSS by webhook or a signed link valid for 24 hours.

Is the CSS minifier API free?

No, there is no free tier or trial; it costs $0.002 per request, and a failed request is never charged.

Will minifying change how my page looks?

No, only whitespace, comments and provably redundant syntax are removed; selector order and specificity are preserved so rendering stays the same.

Does it support modern CSS features like custom properties?

Yes, custom properties, media queries and other standard modern CSS syntax pass through minification intact.

Can I use this instead of a bundler plugin?

Yes, it's built for exactly that: projects without a JavaScript build chain can call the endpoint directly as their minification step.

Can I minify many stylesheets in bulk?

Yes, submit one async task per file and collect each result by webhook, which fits a CI pipeline processing many files at once.

Is this endpoint live?

Yes, data.css_minify is live and accepting requests now.

Is my CSS source stored after minification?

No, both the submitted and minified CSS are deleted after the retention window and never used for training.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/data/css-minify

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, and soon from our app, email and Telegram.

curl -X POST https://api.kit.forhosting.com/data/css-minify \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input":"…"}'
{
  "input": "…"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "data.css_minify",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_mb25
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →