{"id":20164,"library":"json-loader","title":"json-loader","description":"A webpack loader for importing JSON files into JavaScript modules. Version 0.5.7 (latest, stable) is effectively deprecated because webpack >= v2.0.0 natively supports JSON imports. The loader is only useful for custom file extensions or legacy webpack v1 projects. It has minimal maintenance and no active development since 2017. Alternative: rely on webpack's built-in JSON support.","status":"deprecated","version":"0.5.7","language":"javascript","source_language":"en","source_url":"https://github.com/webpack/json-loader","tags":["javascript"],"install":[{"cmd":"npm install json-loader","lang":"bash","label":"npm"},{"cmd":"yarn add json-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add json-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"webpack peer dependency; loader requires webpack to function","package":"webpack","optional":false}],"imports":[{"note":"In webpack v1, this loader is needed. Since webpack v2, JSON files work without this loader.","wrong":"require('json-loader') directly in code (not a JS module)","symbol":"json-loader (loader reference)","correct":"In webpack config: { test: /\\.json$/, loader: 'json-loader' }"},{"note":"Inline usage is for webpack v1; in v2+ just require the JSON file directly.","wrong":"const json = require('json-loader')(require('./file.json'));","symbol":"Inline usage","correct":"const json = require('json-loader!./file.json');"},{"note":"json-loader is not a JavaScript module to import; it's a webpack loader referenced in config.","wrong":"import jsonLoader from 'json-loader'","symbol":"Default import (ES modules)","correct":"import 'json-loader' (no direct use; configured in webpack)"}],"quickstart":{"code":"// webpack.config.js (webpack v1)\nmodule.exports = {\n  entry: './app.js',\n  output: { filename: 'bundle.js' },\n  module: {\n    loaders: [\n      { test: /\\.json$/, loader: 'json-loader' }\n    ]\n  }\n};\n\n// app.js\nvar data = require('./data.json');\nconsole.log(data);","lang":"javascript","description":"Shows how to configure json-loader in webpack v1 to import JSON files."},"warnings":[{"fix":"For webpack v2+, remove json-loader and use built-in JSON handling. If you need a custom file extension, use a different loader.","message":"json-loader is deprecated as webpack v2+ includes JSON support natively.","severity":"deprecated","affected_versions":">=0.5.0"},{"fix":"Update to latest version (0.5.7). This change affects file size but not functionality.","message":"The loader previously used tab indentation in stringified JSON, which was changed to spaces for performance.","severity":"breaking","affected_versions":">=0.5.5"},{"fix":"For webpack v2+, do not use json-loader; just require the JSON file directly.","message":"Inline require('json-loader!./file.json') works in webpack v1 but not in v2+ where JSON is handled differently.","severity":"gotcha","affected_versions":">=0.5.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Add json-loader to webpack config with test: /\\.json$/.","cause":"When webpack v1 is used without json-loader, it cannot parse JSON files.","error":"Module parse failed: Unexpected token (1:1)\nYou may need an appropriate loader to handle this file type."},{"fix":"Remove json-loader from config and let webpack handle JSON natively.","cause":"Using json-loader with webpack v2 or later triggers a deprecation warning.","error":"DeprecationWarning: json-loader is deprecated. Since webpack v2, JSON files are supported by default."},{"fix":"Run: npm install --save-dev json-loader","cause":"json-loader is not installed or not in node_modules.","error":"Cannot find module 'json-loader'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}