vite-plugin-json5 weekly downloads statistics
By sneakylenny · npm · Vite plugins
Plugin for allowing .json5 and .jsonc files to be loaded.
vite-plugin-json5 has 83,247 recorded weekly downloads on npm, an increase of 56.3% over the past 30 days, ranking #666 of 3,247 tracked listings.
About vite-plugin-json5
Vite JSON5 (and JSONC) plugin
A Vite plugin that wraps json5 to allow .json5 and .jsonc files to be loaded.
Installation
1. Install the package
# pnpm
pnpm add -D vite-plugin-json5
# yarn
yarn add -D vite-plugin-json5
# npm
npm install -D vite-plugin-json5
2. Add it to your Vite config
// vite.config.js
import json5Plugin from "vite-plugin-json5";
// or
import { json5Plugin } from "vite-plugin-json5";
export default defineConfig({
plugins: [json5Plugin()],
});
3. Done
.json5 and .jsonc files can now be imported directly. They are parsed by the json5 package and transformed into standard JavaScript modules.
Options
This plugin accepts the same options as the default JSON parser, plus a dts option for automatic TypeScript type generation:
interface Json5Options {
/**
* Generate a named export for every property of the JSON object
* @default true
*/
namedExports?: boolean;
/**
* Generate performant output as JSON.parse("stringified").
* Enabling this will disable namedExports.
* @default false
*/
stringify?: boolean;
/**
* Automatically generate TypeScript declarations for imported
* JSON5/JSONC files. See the TypeScript types section below.
*/
dts?:
| boolean
// Aggregated mode (default): all declarations in one file
| { sidecar?: false; literals?: boolean; outFile?: string }
// Sidecar mode: one .d.ts file next to each source file
| { sidecar: true; literals?: boolean };
}
TypeScript types
[!NOTE] In Vite's dev server, type declarations are generated lazily — the file is written the first time a JSON5/JSONC module is actually requested. Open the page once and the file persists on disk across server restarts. Running
vite buildalways generates types upfront.
Enable the dts option to have the plugin automatically generate TypeScript declarations for every JSON5/JSONC file you import. No more any — you get full type safety and autocompletion, inferred directly from the file's contents.
// vite.config.ts
json5Plugin({ dts: true });
There are two modes:
Aggregated mode (default) — all declarations are collected into a single file at node_modules/@types/vite-plugin-json5/index.d.ts.
For auto-generated types to work, add "vite-plugin-json5" to your tsconfig.json "types" array:
{
"compilerOptions": {
"types": ["vite-plugin-json5"]
}
}
If you already have a "types" array (e.g. "types": ["vite/client"]), append "vite-plugin-json5" to it.
Sidecar mode — writes a .d.ts file next to each source file (e.g. config.json5.d.ts beside config.json5). TypeScript picks these up automatically via module resolution — no tsconfig.json changes needed.
Example:
src/
├── config.json5
├── config.json5.d.ts ← generated
├── theme.jsonc
└── theme.jsonc.d.ts ← generated
Enable it with sidecar: true and add the generated files to your .gitignore:
json5Plugin({ dts: { sidecar: true } });
Add the signature of the generated files to the git ignore to prevent them from being pushed to your repository:
*.json5.d.ts
*.jsonc.d.ts
Literal types — by default, values are widened to their primitive type (string, number, boolean). Pass literals: true to use exact literal types instead:
json5Plugin({ dts: { literals: true } });
// Without literals (default)
export declare const version: string;
// With literals: true
export declare const version: "1.0.0";
Custom output path (aggregated mode only) — change where the aggregated file is written using outFile, relative to the Vite root:
json5Plugin({ dts: { outFile: "src/types/json5.d.ts" } });
Contributing
A guide for setting up the development environment to allow for easy contributions.
This repo uses proto for toolchain management and moon as the task runner.
-
Install proto by following the proto install guide. Then install the required tools (Node.js, pnpm, and moon) from the repo root:
$ proto install -
Install dependencies:
$ pnpm install -
Make changes
-
If the change is user-facing, add a changeset:
$ pnpm changesetCommit the generated file under
.changeset/with your PR. -
Run tests
$ moon run vite-plugin-json5:test -
Build when successful
$ moon run vite-plugin-json5:build -
Run the playground to test the build
$ moon run playground:dev
Releases are automated with changesets. Development lands on dev; merging dev → main (or committing directly to main) runs the release workflow, which opens a Version Packages PR — merge that to publish. See .changeset/README.md.
Description from the npm listing.
- vite
- vite-plugin
- json5
- jsonc
- json
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (592)Similar npm Vite plugins plugins
All 20 vite-plugin-json5 alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/vite-plugin-json5. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.