
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@timkit/css-parser
Advanced tools
A high-performance, character-by-character CSS parser that converts CSS to JavaScript objects and vice versa
A high-performance, character-by-character CSS parser that converts CSS to JavaScript objects and vice versa.
# If the package is published on npm
npm install @timkit/css-parser
# Or install directly from GitHub
npm install github:timkit-dev/css-parser
import { parse } from '@timkit/css-parser';
const css = `
.container {
width: 100px;
height: 200px;
}
.button {
background-color: #ff0000;
}
`;
const cssObject = parse(css);
console.log(JSON.stringify(cssObject, null, 2));
Output:
{
"rules": [
{
"selector": ".container",
"declarations": [
{
"property": "width",
"value": "100px"
},
{
"property": "height",
"value": "200px"
}
]
},
{
"selector": ".button",
"declarations": [
{
"property": "background-color",
"value": "#ff0000"
}
]
}
],
"atRules": []
}
import { stringify } from '@timkit/css-parser';
const cssObject = {
rules: [
{
selector: '.container',
declarations: [
{ property: 'width', value: '100px' },
{ property: 'height', value: '200px' }
]
},
{
selector: '.button',
declarations: [
{ property: 'background-color', value: '#ff0000' }
]
}
]
};
const css = stringify(cssObject);
console.log(css);
Output:
.container {
width: 100px;
height: 200px;
}
.button {
background-color: #ff0000;
}
import { stringify } from '@timkit/css-parser';
const cssObject = {
rules: [
{
selector: '.container',
declarations: [
{ property: 'width', value: '100px' },
{ property: 'height', value: '200px' }
]
},
{
selector: '.button',
declarations: [
{ property: 'background-color', value: '#ff0000' }
]
}
]
};
const css = stringify(cssObject, { compress: true });
console.log(css);
Output:
.container{width:100px;height:200px;}.button{background-color:#ff0000;}
The parser supports various @-rules like @media, @keyframes, @import, etc.
import { parse, stringify } from '@timkit/css-parser';
const css = `
@media (max-width: 768px) {
.container {
width: 100%;
}
}
@keyframes fadeIn {
0% { opacity: 0; }
100% { opacity: 1; }
}
@import url('styles.css');
`;
const cssObject = parse(css);
console.log(JSON.stringify(cssObject, null, 2));
// Convert back to CSS
const regeneratedCss = stringify(cssObject);
console.log(regeneratedCss);
npm test
This project is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.
Copyright 2025 timkit.dev
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
FAQs
A high-performance, character-by-character CSS parser that converts CSS to JavaScript objects and vice versa
We found that @timkit/css-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.