https://github.com/fengzilong/jsonlint
Like ESLint but focus on json lint, also with a smaller size
https://github.com/fengzilong/jsonlint
json lint linter parse
Last synced: 5 months ago
JSON representation
Like ESLint but focus on json lint, also with a smaller size
- Host: GitHub
- URL: https://github.com/fengzilong/jsonlint
- Owner: fengzilong
- License: mit
- Created: 2021-07-25T12:11:59.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-08-30T18:17:19.000Z (almost 2 years ago)
- Last Synced: 2025-09-29T16:31:45.151Z (9 months ago)
- Topics: json, lint, linter, parse
- Language: JavaScript
- Homepage:
- Size: 190 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jsonlint
[](https://github.com/fengzilong/jsonlint/actions)

[](https://www.npmjs.com/package/@biu/jsonlint)
## Screenshot

## Features
- ⚔️ Lint all errors at once
- 🌈 Human-friendly, intuitive message to stdout
- 🚀 Smaller than ESLint
## Installation
For NPM users
```bash
npm i @biu/jsonlint
```
for yarn users
```bash
yarn add @biu/jsonlint
```
## API
```js
const { lint, format } = require( '@biu/jsonlint' )
const result = lint( string, options )
const prettied = format( result )
console.log( result.codeframe ) // or console.log( prettied )
```
`prettied` looks like [Screenshot](#screenshot)
`result` looks like
```js
{
source: '', // source code
errors: [], // with keys: `{ line, column, message, severity }`
comments: [], // with keys: `{ start: { line, column }, end: { line, column } }`
codeframe: '', // codeframe with error locations and syntax highlight
}
```
### string
Type: `String`
### options.allowComments
By default it reports all comments as error, if you want to remove comment from errors, set `allowComments` to `true`
## Difference with `try/catch + JSON.parse`
`JSON.parse` is not fault tolerant, so it cann't continue after seeing first error, while this library using a fault tolerant parser to avoid this
## License
MIT