/cssjson-cli

CLI utility for converting CSS :left_right_arrow: JSON

Primary LanguageJavaScriptMIT LicenseMIT

npm version

cssjson-cli

A CLI utility for CSSJSON. Converts the contents of a CSS file to JSON (or vice-versa).

Installation

$ npm install -g cssjson-cli

Usage

$ 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": {}
}

Examples

CSS -> JSON

cssjson input.css -o output.json

JSON -> CSS

cssjson input.js --to-css -o output.css

Options

to-css

####--to-css
Convert JSON -> CSS.

output

####-o, --output [output_file]
A target file to output the result to. If this flag isn't included, cssjson will output to stdout.

help

####-h, --help Show help

License

MIT