ToolGlobal

Minifier Studio

Detector rack

Input

Paste JS, CSS, or HTML below. Everything runs locally in your browser; nothing is uploaded.

Try a sample:

Output

\n'+ '\n' }; var currentInput=''; var currentOutput=''; var detectedType='auto'; var openMod=null; function $id(id){return document.getElementById(id);} function el(tag,cls,text){ var n=document.createElement(tag); if(cls)n.className=cls; if(text!==undefined&&text!==null)n.textContent=String(text); return n; } function setDet(name,state,detail){ var mod=$id('mod-'+name); var led=$id('led-'+name); var st=$id('status-'+name); mod.className='module '+state; led.className='led '+state; st.textContent=state.toUpperCase(); st.className='mod-status '+state; mod.setAttribute('data-state',state); mod.setAttribute('data-detail',detail||''); } function escapeHtml(s){ return String(s).replace(/&/g,'&').replace(//g,'>'); } function protectStrings(code){ var parts=[]; var literals=[]; var i=0; var n=code.length; while(i0){depth--;j++;continue;} if(code[j]==='`'&&depth===0){j++;break;} j++; } literals.push(code.slice(i,j)); parts.push('\x00S'+(literals.length-1)+'\x00'); i=j; }else{ parts.push(ch); i++; } } return{code:parts.join(''),literals:literals}; } function restoreStrings(code,literals){ return code.replace(/\x00S(\d+)\x00/g,function(m,idx){ return literals[parseInt(idx,10)]; }); } function detectLanguage(code){ var s=code.trim(); if(!s)return 'unknown'; if(/]|]|]|]/i.test(s))return 'html'; if(/<\/?[a-z][\s\S]*>/i.test(s)&&/<(div|span|p|a|img|ul|ol|li|section|article|nav|header|footer|main|script|style|link|meta|h[1-6])[\s>]/i.test(s))return 'html'; if(/\{[\s\S]*\}/.test(s)&&/function\s|const\s|let\s|var\s|=>|import\s|export\s|class\s|return\s|if\s*\(|for\s*\(|while\s*\(/.test(s))return 'js'; if(/@media\s|@import\s|@keyframes\s|@font-face|:root\s*\{|#[0-9a-fA-F]{3,8}\b|var\(--|:\s*\d+px|:\s*\d+em|:\s*\d+%|:\s*none|:\s*inherit|:\s*flex|:\s*grid/.test(s))return 'css'; if(/^\s*\/[/*]/m.test(s)&&/\{[\s\S]*\}/.test(s)&&/:\s*[^;]+;/.test(s))return 'css'; return 'unknown'; } function countComments(code,type){ var count=0; if(type==='js'){ var re=/(\/\/[^\n]*|\/\*[\s\S]*?\*\/)/g; var m; while((m=re.exec(code))!==null)count++; }else if(type==='css'){ var re2=/(\/\*[\s\S]*?\*\/)/g; var m2; while((m2=re2.exec(code))!==null)count++; }else if(type==='html'){ var re3=(//g); var m3; while((m3=re3.exec(code))!==null)count++; } return count; } function countBlankLines(code){ var lines=code.split('\n'); var blank=0; for(var i=0;i0&&/^\s*$/.test(result[result.length-1]))continue; result.push(line); } out=result.join('\n'); out=out.replace(/\n\s*\n/g,'\n'); out=out.replace(/\s*([{}();,=:+\-*/<>!&|?])\s*/g,'$1'); out=out.replace(/\s*\n\s*/g,'\n'); var lines2=out.split('\n'); var final=[]; for(var j=0;j/g,''); out=out.replace(//g,''); var scriptBlocks=[]; var styleBlocks=[]; out=out.replace(/([\s\S]*?)<\/script>/gi,function(match,attrs,body){ var idx=scriptBlocks.length; scriptBlocks.push(body); return '__SCRIPT_'+idx+''; }); out=out.replace(/([\s\S]*?)<\/style>/gi,function(match,attrs,body){ var idx=styleBlocks.length; styleBlocks.push(body); return '__STYLE_'+idx+''; }); out=out.replace(/\s+/g,' '); out=out.replace(/>\s+<'); out=out.replace(/\s+>/g,'>'); out=out.replace(/<\s+/g,'<'); for(var i=0;i0?Math.round((1-result.outputSize/code.length)*100):0; if(type==='js'){ if(/`[\s\S]*\$\{/.test(code)){ result.warnings.push('Template literal with interpolation detected — minification is safe but review output for correctness.'); } if(/\/[^/]+\/[gimsuy]*/.test(code)&&/(?:^|[=(!&|?:,;\[{+\-~])\s*\/[^/]+\/[gimsuy]*/.test(code)){ result.warnings.push('Regex literal detected — regex content is preserved but surrounding context is minified.'); } if(/]/i.test(minified)){ result.warnings.push('Output contains HTML-like content — verify this is intentional.'); } } if(type==='html'){ var scriptMatch=code.match(/]*>([\s\S]*?)<\/script>/gi); if(scriptMatch){ for(var s=0;s]*>/gi,''); if(body.length>0&&body.length0; var verdictEl=$id('verdict'); var statEl=$id('statrow'); var outputEl=$id('output-area'); var copyBtn=$id('copy-out-btn'); var dlBtn=$id('download-btn'); var ratioPill=$id('ratio-pill'); statEl.replaceChildren(); outputEl.textContent=''; verdictEl.className='verdict'; ratioPill.textContent=''; ratioPill.className='pill'; copyBtn.disabled=true; dlBtn.disabled=true; currentOutput=''; if(!hasInput){ verdictEl.textContent=''; statEl.appendChild(el('span','stat','Awaiting input')); for(var j=0;j0){ ratioPill.textContent=res.ratio+'% smaller'; ratioPill.className='pill good'; }else if(res.ratio===0){ ratioPill.textContent='No change'; ratioPill.className='pill warn'; }else{ ratioPill.textContent='Larger (+'+Math.abs(res.ratio)+'%)'; ratioPill.className='pill risk'; } if(res.warnings.length>0){ verdictEl.className='verdict warn show'; verdictEl.textContent=res.warnings[0]; }else if(res.ratio>0){ verdictEl.className='verdict ok show'; verdictEl.textContent='Minified successfully. '+res.ratio+'% size reduction ('+res.inputSize+' B → '+res.outputSize+' B).'; }else{ verdictEl.className='verdict warn show'; verdictEl.textContent='No size reduction achieved. The input may already be minified or too short.'; } outputEl.textContent=res.output; copyBtn.disabled=false; dlBtn.disabled=false; setDet('detect','ok','Detected: '+res.type.toUpperCase()); if(res.commentsRemoved>0)setDet('comments','ok',res.commentsRemoved+' comment'+(res.commentsRemoved>1?'s':'')+' removed.'); else setDet('comments','ok','No comments found.'); setDet('whitespace','ok','Whitespace compressed.'); if(res.warnings.length>0)setDet('safe','warn',res.warnings.length+' warning'+(res.warnings.length>1?'s':'')+'.'); else setDet('safe','ok','No semantic changes detected.'); if(res.ratio>0)setDet('ratio','ok',res.ratio+'% reduction.'); else if(res.ratio===0)setDet('ratio','warn','No size change.'); else setDet('ratio','warn','Output is larger.'); setDet('result','ok','Ready to copy.'); } function openPanel(mod){ openMod=mod; var body=$id('panel-body'); var meta=null; body.replaceChildren(); for(var i=0;i0; var sec=el('div','panel-section'); sec.appendChild(el('h3','','Current status')); if(!hasInput){ sec.appendChild(el('p','panel-note','No code minified yet.')); }else{ var modEl=$id('mod-'+mod); var state=modEl.getAttribute('data-state')||'off'; var detail=modEl.getAttribute('data-detail')||'No details.'; sec.appendChild(el('p','panel-note','Status: '+state.toUpperCase())); sec.appendChild(el('p','panel-note',detail)); } body.appendChild(sec); $id('panel').classList.add('open'); $id('panel-backdrop').classList.add('open'); } function closePanel(){ openMod=null; $id('panel').classList.remove('open'); $id('panel-backdrop').classList.remove('open'); } function copyText(text,btn){ if(!text)return; function flash(){ if(!btn)return; var old=btn.textContent; btn.textContent='Copied'; window.setTimeout(function(){btn.textContent=old;},900); } function fallback(){ var ta=document.createElement('textarea'); ta.value=text; ta.style.position='fixed'; ta.style.opacity='0'; document.body.appendChild(ta); ta.select(); try{document.execCommand('copy');}catch(e){} document.body.removeChild(ta); flash(); } if(navigator.clipboard&&navigator.clipboard.writeText){ navigator.clipboard.writeText(text).then(flash).catch(fallback); }else fallback(); } function getExt(type){ if(type==='js')return '.js'; if(type==='css')return '.css'; if(type==='html')return '.html'; return '.txt'; } function boot(){ for(var i=0;i0)renderResults(); }); $id('minify-btn').addEventListener('click',renderResults); $id('clear-btn').addEventListener('click',function(){ $id('code-input').value=''; renderResults(); }); $id('copy-out-btn').addEventListener('click',function(){ copyText(currentOutput,$id('copy-out-btn')); }); $id('download-btn').addEventListener('click',function(){ if(!currentOutput)return; var type=detectedType; if(type==='auto')type=detectLanguage(currentInput); if(type==='unknown')type='js'; var blob=new Blob([currentOutput],{type:'text/plain'}); var url=URL.createObjectURL(blob); var a=document.createElement('a'); a.href=url; a.download='minified'+getExt(type); document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); }); $id('examples').addEventListener('click',function(e){ var t=e.target; if(t&&t.classList&&t.classList.contains('ex-tag')){ var name=t.getAttribute('data-ex'); $id('code-input').value=EXAMPLES[name]||''; detectedType='auto'; var btns=$id('type-selector').querySelectorAll('.type-btn'); for(var i=0;i