CLI utility for CSS<->JSON (https://github.com/aramk/CSSJSON)
npm install cssjson-cli
$ npm install -g cssjson-cli
`Usage
cssjson converts css to JSON. To convert JSON to CSS, use the --to-css flag.
`
$ cssjson input_file [--to-css] [--output|-o output_file]
`By default,
cssjson outputs to stdout. You can specify an output file with the --output flag:
`
$ cssjson style.css --output style.js
`It converts a file like this:
`css
.btn {
background: #bbb;
padding: 0.5rem;
font-size: 1rem;
}.btn-primary {
background: red;
color: #fff;
}
`into one like this:
`json
{
"children": {
".btn": {
"children": {},
"attributes": {
"background": "#bbb",
"padding": "0.5rem",
"font-size": "1rem"
}
},
".btn-primary": {
"children": {},
"attributes": {
"background": "red",
"color": "#fff"
}
}
},
"attributes": {}
}
`Examples
CSS -> JSON
`
cssjson input.css -o output.json
`
JSON -> CSS
`
cssjson input.js --to-css -o output.css
`Options
$3
--to-css
Convert JSON -> CSS.$3
-o, --output [output_file]
A target file to output the result to. If this flag isn't included, cssjson will output to stdout.$3
-h, --help`