A Node.js utility to read and parse JSON files with UTF-8 BOM stripping and configurable parsing options.
load-json-file is a Node.js package that reads and parses JSON files from the filesystem. It solves common issues like UTF-8 byte order mark (BOM) interference and provides both asynchronous and synchronous methods for flexible integration. The package includes options for preprocessing JSON strings and transforming parsed data using reviver functions.
Node.js developers who need to read JSON configuration files, data stores, or any JSON-formatted files in their applications, especially those dealing with files that may include BOMs or require custom parsing logic.
Developers choose load-json-file for its simplicity, reliability in handling BOMs, and dual API support. It reduces boilerplate code and parsing errors compared to manual `fs.readFile` + `JSON.parse` implementations, and it integrates seamlessly with its companion package write-json-file for complete JSON file management.
Read and parse a JSON file
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Strips UTF-8 byte order marks transparently, preventing common parsing errors that occur with files saved by editors like Notepad.
Offers both Promise-based async (loadJsonFile) and synchronous (loadJsonFileSync) methods, fitting into various Node.js workflows without extra boilerplate.
Supports beforeParse and reviver functions, allowing preprocessing of JSON strings and transformation of parsed data, as detailed in the README examples.
Handles edge cases like BOMs and provides a clean API, minimizing errors compared to manual fs.readFile and JSON.parse implementations.
Limited to reading local JSON files; it cannot fetch JSON from URLs or other sources without additional HTTP client code.
Lacks built-in support for streaming large files, JSON Schema validation, or complex manipulations, relying on external packages for such needs.
For basic JSON reading without BOM issues, native Node.js methods might suffice, making this package an unnecessary addition to the project.