Minify JS, CSS & HTML Online
Minify JavaScript (Terser), CSS (CSSO), HTML and JSON, with the byte and gzip size before and after; the language is detected automatically.
Result
Press “Run” to see the result.
The minifier shrinks front-end code for production. JavaScript goes through Terser (two compression passes, local names mangled, module=true for ES modules), CSS through CSSO (merges rules, shortens colours and values, restructure=false for a safer pass), JSON is re-serialised without whitespace, and HTML loses comments and whitespace between block tags while its inline <script> and <style> blocks are minified too.
Leave type empty to detect the language from the code, or set js, css, html or json. License comments (/*! … */, @license, @preserve) are kept. In HTML, <pre> and <textarea> content is left untouched, one space is kept between inline tags, and minify_js=false / minify_css=false leave embedded code as it is.
The answer gives the minified code and size: input and output bytes, the percentage saved and gzip sizes, the number that matters for download time. Syntax errors return parse_error with the line and column.
Use this in your code
curl -X POST "https://apibox.io.vn/v1/minify" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"code":"function tinhTong(soThuNhat, soThuHai) {\n // cộng hai số\n const tong = soThuNhat + soThuHai;\n return tong;\n}\nconsole.log(tinhTong(1, 2));"}'const res = await fetch('https://apibox.io.vn/v1/minify', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"code": "function tinhTong(soThuNhat, soThuHai) {\n // cộng hai số\n const tong = soThuNhat + soThuHai;\n return tong;\n}\nconsole.log(tinhTong(1, 2));"
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/minify",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"code": "function tinhTong(soThuNhat, soThuHai) {\n // cộng hai số\n const tong = soThuNhat + soThuHai;\n return tong;\n}\nconsole.log(tinhTong(1, 2));"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/minify');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"code":"function tinhTong(soThuNhat, soThuHai) {\\n // cộng hai số\\n const tong = soThuNhat + soThuHai;\\n return tong;\\n}\\nconsole.log(tinhTong(1, 2));"}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));API documentation → Get a free API key
FAQ
Is my code changed in behaviour?
Terser and CSSO apply safe transformations. If a script relies on function names, send mangle=false.
Does it support TypeScript or SCSS?
No: compile to JavaScript or CSS first, then minify.
What is the size limit?
2,000,000 characters of code per call.