A CLI utility for CSSJSON. Converts the contents of a CSS file to JSON (or vice-versa).
$ npm install -g cssjson-cli
$ cssjson input_file [--to-css] [--output|-o output_file]
By default, cssjson
converts CSS to JSON. To convert JSON to CSS, use the --to-css
flag.
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:
.btn {
background: #bbb;
padding: 0.5rem;
font-size: 1rem;
}
.btn-primary {
background: red;
color: #fff;
}
into one like this:
{
"children": {
".btn": {
"children": {},
"attributes": {
"background": "#bbb",
"padding": "0.5rem",
"font-size": "1rem"
}
},
".btn-primary": {
"children": {},
"attributes": {
"background": "red",
"color": "#fff"
}
}
},
"attributes": {}
}
CSS -> JSON
cssjson input.css -o output.json
JSON -> CSS
cssjson input.js --to-css -o output.css
####--to-css
Convert JSON -> CSS.
####-o, --output [output_file]
A target file to output the result to. If this flag isn't included, cssjson
will output to stdout
.
####-h, --help
Show help