Pages

Saturday, 21 December 2024

CSS Minifier Tool



CSS Minifier Tool

CSS Minifier Tool

Paste your CSS code below, and we'll minify it for you!

Made with ❤️ | Responsive Design

/* General Reset */ body, html { margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #f9f9f9; color: #333; } /* Container Styling */ .container { max-width: 800px; margin: 20px auto; padding: 20px; border-radius: 10px; background: linear-gradient(145deg, #ffffff, #e6e6e6); box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1); } /* Header Styling */ header { text-align: center; margin-bottom: 20px; } header h1 { font-size: 2rem; color: #4a90e2; } header p { color: #555; } /* Textarea Styling */ textarea { width: 100%; height: 150px; margin: 10px 0; padding: 10px; border: 1px solid #ddd; border-radius: 5px; font-size: 1rem; resize: none; background-color: #fff; box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1); } /* Button Styling */ button { display: inline-block; width: 100%; padding: 10px; margin: 10px 0; border: none; border-radius: 5px; font-size: 1rem; font-weight: bold; color: #fff; background: linear-gradient(145deg, #4a90e2, #357abd); cursor: pointer; transition: all 0.3s ease; } button:hover { background: linear-gradient(145deg, #357abd, #4a90e2); } button:active { transform: scale(0.98); } /* Footer Styling */ footer { text-align: center; margin-top: 20px; font-size: 0.9rem; color: #888; } /* Responsive Design */ @media (max-width: 600px) { header h1 { font-size: 1.5rem; } textarea { height: 120px; } button { font-size: 0.9rem; } } // Initialize Clipboard.js for the Copy to Clipboard button new ClipboardJS('#copy-btn'); // Minify CSS function document.getElementById('minify-btn').addEventListener('click', function () { const cssInput = document.getElementById('css-input').value; if (!cssInput.trim()) { alert('Please enter some CSS code!'); return; } // Minify CSS (removing whitespace, comments, etc.) const minifiedCSS = cssInput .replace(/\/\*[\s\S]*?\*\//g, '') // Remove comments .replace(/\s{2,}/g, ' ') // Remove extra spaces .replace(/\s*({|}|:|;|,)\s*/g, '$1') // Remove spaces around symbols .replace(/;}/g, '}'); // Remove unnecessary semicolons document.getElementById('css-output').value = minifiedCSS; });