Need help with rollup-plugin-json?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

129 Stars 21 Forks 80 Commits 0 Opened issues


This module has moved and is now available at @rollup/plugin-json /

Services available


Need anything else?

Contributors list


This module has moved and is now available at @rollup/plugin-json. Please update your dependencies. This repository is no longer maintained.


Convert .json files to ES6 modules:

// import a single property from a JSON file,
// discarding the rest
import { version } from './package.json';
console.log( `running version ${version}` );

// import the whole file as an object import pkg from './package.json'; console.log( running version ${pkg.version} );


npm install --save-dev rollup-plugin-json


// rollup.config.js
import json from 'rollup-plugin-json';

export default { input: 'src/main.js', output: { file: 'dist/bundle.js', format: 'iife' },

plugins: [ json({ // All JSON files will be parsed by default, // but you can also specifically include/exclude files include: 'node_modules/', exclude: [ 'node_modules/foo/', 'node_modules/bar/**' ],

  // for tree-shaking, properties will be declared as
  // variables, using either `var` or `const`
  preferConst: true, // Default: false

  // specify indentation for the generated default export —
  // defaults to '\t'
  indent: '  ',

  // ignores indent and generates the smallest code
  compact: true, // Default: false

  // generate a named export for every property of the JSON object
  namedExports: true // Default: true

] };



We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.