There's no way to directly handle JSON with SCSS alone. Since you're already using Gulp, you can use an third-party tool such as eyeglass or sassport to convert JSON into a SCSS hash. Another tool available is json-sass, which you can use standalone.

If you're not using Gulp, then you would have to rely on Gem based converters but they don't seem to be actively maintained:

  • https://github.com/vigetlabs/sass-json-vars
  • https://github.com/HugoGiraudel/SassyJSON
Answer from allejo on Stack Overflow
🌐
npm
npmjs.com › package › scss-to-json
scss-to-json - npm
This package allows you to use your SCSS variables in your JS code. Specifically, it takes a SCSS variable file (example below) and will parse, run Sass functions, and convert to JSON format.
      » npm install scss-to-json
    
Published   Oct 31, 2017
Version   2.0.0
Author   Ryan Bahniuk
🌐
GitHub
github.com › ryanbahniuk › scss-to-json
GitHub - ryanbahniuk/scss-to-json: A package to require SCSS variables in JSON format · GitHub
This package allows you to use your SCSS variables in your JS code. Specifically, it takes a SCSS variable file (example below) and will parse, run Sass functions, and convert to JSON format.
Starred by 51 users
Forked by 42 users
Languages   JavaScript 95.2% | CSS 4.8%
🌐
npm
npmjs.com › package › json-to-scss
json-to-scss - npm
A small utility to convert js & json file(s) to scss/sass file(s).. Latest version: 1.6.2, last published: 5 years ago. Start using json-to-scss in your project by running `npm i json-to-scss`. There are 10 other projects in the npm registry ...
      » npm install json-to-scss
    
Published   Sep 18, 2020
Version   1.6.2
Author   Renaud Lapoële
🌐
npm
npmjs.com › package › @crocsx › scss-to-json
@crocsx/scss-to-json - npm
This package allows you to use your SCSS variables in your JS code. Specifically, it takes a SCSS variable file (example below) and will parse, run Sass functions, and convert to JSON format.
      » npm install @crocsx/scss-to-json
    
Published   Feb 19, 2021
Version   3.0.0
Author   Federico Giacomini
🌐
CSS-Tricks
css-tricks.com › making-sass-talk-to-javascript-with-json
Making Sass talk to JavaScript with JSON | CSS-Tricks
August 3, 2021 - Now before parse the JSON in the return of our getBreakpoint function we just pass the string through our removeQuotes function. ... JavaScript can now read the label that we defined for each breakpoint. It’s trivial at this point to match that label to a responsive image source.
🌐
GitHub
github.com › plentycode › sass-export
GitHub - plentycode/sass-export: Exports your scss files to Json. Easily convert your SCSS files into Json.
Exports your scss files to Json. Easily convert your SCSS files into Json. - plentycode/sass-export
Starred by 59 users
Forked by 29 users
Languages   TypeScript 87.7% | SCSS 10.0% | JavaScript 2.3% | TypeScript 87.7% | SCSS 10.0% | JavaScript 2.3%
Find elsewhere
🌐
Oddbird
oddbird.net › herman › docs › api_json-export
Exporting Styles to JSON | Herman Documentation
Encode a Sass map as a JSON-ready string, and print to CSS output as a persistent comment.
🌐
CodeSandbox
codesandbox.io › examples › package › scss-to-json
scss-to-json examples - CodeSandbox
Use this online scss-to-json playground to view and fork scss-to-json example apps and templates on CodeSandbox.
🌐
Reddit
reddit.com › r/webdev › is there a way to convert scss to json?
r/webdev on Reddit: Is there a way to convert SCSS to JSON?
June 14, 2016 -

Hi,

I am looking for a solution that can convert SCSS (including maps, mixins, variables etc) to a JSON file as the output. It should be ideally part of the build process using any of the build tools such as webpack, grunt etc.

I tried a bunch of them - SassyJSON, sass-json-export etc. The latter works well with maps, but not mixins.

Any pointers on how we can compile SCSS to JSON?

Thanks!

🌐
npm
npmjs.com › package › scss-json
scss-json - npm
This package allows you to use your SCSS variables in your JS code. Specifically, it takes a SCSS variable file (example below) and will parse, run Sass functions, and convert to JSON format.
      » npm install scss-json
    
Published   Apr 21, 2022
Version   1.0.0
Author   Jair Medeiros
🌐
Viget
viget.com › articles › sharing-data-between-sass-and-javascript-with-json
Sharing Data Between Sass and JavaScript with JSON | Viget
May 29, 2018 - After requiring it, this gem allows JSON files to be included as valid @import paths; converting the top level values into any of the Sass data types (strings, maps, lists).
🌐
GitHub
github.com › Crocsx › scss-to-json
GitHub - Crocsx/scss-to-json: A package to require SCSS variables in JSON format
This package allows you to use your SCSS variables in your JS code. Specifically, it takes a SCSS variable file (example below) and will parse, run Sass functions, and convert to JSON format.
Starred by 2 users
Forked by 43 users
Languages   JavaScript 95.3% | SCSS 4.7% | JavaScript 95.3% | SCSS 4.7%
🌐
CodeSandbox
codesandbox.io › examples › package › json-to-scss
json-to-scss examples - CodeSandbox
Use this online json-to-scss playground to view and fork json-to-scss example apps and templates on CodeSandbox.
🌐
Medium
medium.com › @premchandkumar › json-to-scss-conversion-3ad6943e3cb9
JSON to SCSS conversion. Hello There, | by Premchand Kumar | Medium
February 17, 2017 - Being an Ionic developer, I found a plug-in, which converts JSON data into SCSS file which can be used as the resolution. It is available at NPM as “scss-to-json”
🌐
GitHub
github.com › ACloudGuru › scss-to-json
GitHub - ACloudGuru/scss-to-json: A package to require SCSS variables in JSON format
This package allows you to use your SCSS variables in your JS code. Specifically, it takes a SCSS variable file (example below) and will parse, run Sass functions, and convert to JSON format.
Forked by 2 users
Languages   JavaScript 95.2% | CSS 4.8% | JavaScript 95.2% | CSS 4.8%
🌐
Stack Overflow
stackoverflow.com › questions › 44743080 › how-to-convert-sass-scss-into-json
css - How to convert sass (scss) into json? - Stack Overflow
I want to convert SASS (scss) into json format. I see some node.js libraries out there like these https://www.npmjs.com/package/sass-json-export https://www.npmjs.com/package/scss-to-json https://...