npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gulp-json-css

v0.2.3

Published

Gulp plugin for turning JSON files into files of scss/sass/less variable definitions.

Downloads

248

Readme

Gulp-json-css

Gulp plugin for turning JSON files into files of scss/sass/less variable definitions. This plugin is based on https://www.npmjs.com/package/gulp-json-sass

Issues should be reported on the issue tracker.

Now you can share configurations between your CSS files and Javascript!

Supports all JSON objects, including nested objects, arrays and keys which are not legal key names. Variable names that begin with a number will be prefixed and such containing illegal characters will have those characters removed.

Ignores (passes through) files with a extensions other than .json.

Installation

npm install gulp-json-css --save-dev

Example

In this example gulpfile, a JSON file is turned into a file of scss variables, concatenated with a scss file, and compiled using gulp-sass.

var jsonCss = require('gulp-json-css'),
    gulp = require('gulp'),
    concat = require('gulp-concat'),
    sass = require('gulp-sass');

gulp.task('scss', function() {
  return gulp
    .src(['example.json', 'example.scss'])
    .pipe(jsonCss())
    .pipe(concat('output.scss'))
    .pipe(sass())
    .pipe(gulp.dest('out/'));
});

API

jsonCss(options)

Returns: stream

options

Type: object

targetPre

Type: string (scss|sass|less)
Default: scss

Defines the target preprocessor for which JSON files should be converted.

delim

Type: string
Default: -

Delimiter used to chain nested objects keys to a simple variables. For example, if delim is '-', then

{
  "someObject" : {
    "someKey" : 123
  }
}

will be converted into (in SCSS):

$someObject-someKey: 123;

Note that keys themselves can contain the delimiter. No attempt is made to ensure that variable names are unique.

keepObjects

Type: boolean
Default: false

Instead of creating a variable with every object value you can instead convert objects to maps and arrays to lists. With the example above you'd get this output instead (still SCSS):

$someObject: (someKey 123);

And with a more complex setup:

{
	"anArray": [1, 2, 3],
	"anObject": {
		"aSubObject": {
			"key1": "value1",
			"key2": "value2"
		},
		"aSubArray": [4, 5, 6]
	}
}

This output (the actual output is flattened into one line):

$anArray: (1, 2, 3);
$anObject: (
	aSubObject: (
		key1: value1,
		key2: value2
	),
	aSubArray: (4, 5, 6)
);

Note that you can only build simple lists in LessCSS.

Since LessCSS does not allow for nested objects or objects in general for that matter, we can only convert arrays to lists, so for objects we go back to chaining keys to simple variables. Output with the above setup:

@anObject-anArray: 1, 2, 3;
@anObject-aSubObject-key1: value1;
@anObject-aSubObject-key2: value2;
@anObject-aSubArray: 4, 5, 6;
numberPrefix

Type: string
Default: _

What string is used to prefix numeric keys, it is necessary since variables aren't allowed to start with a number. This means that the following object:

{
  "1maca" : {
    "2maca" : "asdf"
  },
  "3maca" : "rena"
}

Will result in (SCSS):

$_1maca-2maca: asdf;
$_3maca: rena;

Note that chained sub keys won't be prefixed since it's not necessary anymore, if you use the keepObjects setting though, every key starting with a number will be prefixed.

$_1maca: (_2maca asdf);
$_3maca: rena;
ignoreJsonErrors
  • Type: boolean
  • Default: false

If true, malformed JSON does not result in the plugin emitting an error.

License

MIT.