Skip to content


GitHub stars GitHub release (latest SemVer) GitHub last commit GitHub commit activity GitHub contributors

jsonlint documentation

jsonlint - GitHub

Configuration in MegaLinter

Variable Description Default value
JSON_JSONLINT_ARGUMENTS User custom arguments to add in linter CLI call
Ex: -s --foo "bar"
JSON_JSONLINT_FILTER_REGEX_INCLUDE Custom regex including filter
Ex: (src\|lib)
Include every file
JSON_JSONLINT_FILTER_REGEX_EXCLUDE Custom regex excluding filter
Ex: (test\|examples)
Exclude no file
JSON_JSONLINT_CLI_LINT_MODE Override default CLI lint mode
- file: Calls the linter for each file
- list_of_files: Call the linter with the list of files as argument
- project: Call the linter from the root of the project
JSON_JSONLINT_FILE_EXTENSIONS Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all files
Ex: [".py", ""]
JSON_JSONLINT_FILE_NAMES_REGEX File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files
Ex: ["Dockerfile(-.+)?", "Jenkinsfile"]
Include every file
JSON_JSONLINT_PRE_COMMANDS List of bash commands to run before the linter None
JSON_JSONLINT_POST_COMMANDS List of bash commands to run after the linter None
JSON_JSONLINT_CONFIG_FILE jsonlint configuration file name
Use LINTER_DEFAULT to let the linter find it
JSON_JSONLINT_RULES_PATH Path where to find linter configuration file Workspace folder, then MegaLinter default rules
JSON_JSONLINT_DISABLE_ERRORS Run linter but consider errors as warnings false
JSON_JSONLINT_DISABLE_ERRORS_IF_LESS_THAN Maximum number of errors allowed 0

MegaLinter Flavours

This linter is available in the following flavours

Flavor Description Embedded linters Info
all Default MegaLinter Flavor 112 Docker Image Size (tag) Docker Pulls
ci_light Optimized for CI items (Dockerfile, Jenkinsfile, JSON/YAML schemas,XML 20 Docker Image Size (tag) Docker Pulls
cupcake MegaLinter for the most commonly used languages 80 Docker Image Size (tag) Docker Pulls
documentation MegaLinter for documentation projects 47 Docker Image Size (tag) Docker Pulls
dotnet Optimized for C, C++, C# or VB based projects 59 Docker Image Size (tag) Docker Pulls
go Optimized for GO based projects 49 Docker Image Size (tag) Docker Pulls
java Optimized for JAVA based projects 50 Docker Image Size (tag) Docker Pulls
javascript Optimized for JAVASCRIPT or TYPESCRIPT based projects 56 Docker Image Size (tag) Docker Pulls
php Optimized for PHP based projects 50 Docker Image Size (tag) Docker Pulls
python Optimized for PYTHON based projects 57 Docker Image Size (tag) Docker Pulls
ruby Optimized for RUBY based projects 47 Docker Image Size (tag) Docker Pulls
rust Optimized for RUST based projects 47 Docker Image Size (tag) Docker Pulls
salesforce Optimized for Salesforce based projects 50 Docker Image Size (tag) Docker Pulls
swift Optimized for SWIFT based projects 47 Docker Image Size (tag) Docker Pulls
terraform Optimized for TERRAFORM based projects 52 Docker Image Size (tag) Docker Pulls

Behind the scenes

How are identified applicable files

  • File extensions: .json

How the linting is performed

  • jsonlint is called once with the list of files as arguments (list_of_files CLI lint mode)

Example calls

jsonlint myfile1.json myfile2.json

Help content

Usage: jsonlint [options] [<file, directory, pattern> ...]

JSON/CJSON/JSON5 parser, syntax and schema validator and pretty-printer.

  -f, --config [file]          read options from a custom configuration file
  -F, --no-config              disable searching for configuration files
  -s, --sort-keys              sort object keys (not when prettifying)
  -E, --extensions [ext]       file extensions to process for directory walk
                               (default: ["json","JSON"])
  -i, --in-place               overwrite the input files
  -j, --diff                   print difference instead of writing the output
  -k, --check                  check that the input is equal to the output
  -t, --indent [num|char]      number of spaces or specific characters to use
                               for indentation (default: 2)
  -c, --compact                compact error display
  -M, --mode [mode]            set other parsing flags according to a format
                               type (default: "json")
  -B, --bom                    ignore the leading UTF-8 byte-order mark
  -C, --comments               recognize and ignore JavaScript-style comments
  -S, --single-quoted-strings  support single quotes as string delimiters
  -T, --trailing-commas        ignore trailing commas in objects and arrays
  -D, --no-duplicate-keys      report duplicate object keys as an error
  -V, --validate [file]        JSON schema file to use for validation
  -e, --environment [env]      which specification of JSON Schema the
                               validation file uses
  -x, --context [num]          line count used as the diff context (default: 3)
  -l, --log-files              print only the parsed file names to stdout
  -q, --quiet                  do not print the parsed json to stdout
  -n, --continue               continue with other files if an error occurs
  -p, --pretty-print           prettify the input instead of stringifying the
                               parsed object
  -P, --pretty-print-invalid   force pretty-printing even for invalid input
  -r, --trailing-newline       ensure a line break at the end of the output
  -R, --no-trailing-newline    ensure no line break at the end of the output
  --prune-comments             omit comments from the prettified output
  --strip-object-keys          strip quotes from object keys if possible
  --enforce-double-quotes      surrounds all strings with double quotes
  --enforce-single-quotes      surrounds all strings with single quotes (JSON5)
  --trim-trailing-commas       omit trailing commas from objects and arrays
  -v, --version                output the version number
  -h, --help                   display help for command

You can use BASH patterns for including and excluding files (only files).
Patterns are case-sensitive and have to use slashes as directory separators.
A pattern to exclude from processing starts with "!".

Parsing mode can be "cjson" or "json5" to enable other flags automatically.
If no files or directories are specified, stdin will be parsed. Environments
for JSON schema validation are "json-schema-draft-04", "json-schema-draft-06"
or "json-schema-draft-07". If not specified, it will be auto-detected.

Installation on mega-linter Docker image