Skip to main content

tomllint

A TOML Linter. Checks for basic syntactic errors in any TOML file.

Installation

$ pip install tomllint

Usage

Usage is self explanatory, simply name the files to lint, or use - to indicate that it should read from stdin.

usage: tomllint [-h] [--verbose] toml_file [toml_file ...]

positional arguments:
  toml_file      TOML filenames or "-" for stdin

options:
  -h, --help     show this help message and exit
  --verbose, -v  emit an info diagnostic for each file that lints successfully

By default tomllint is silent on success and only reports errors. Pass --verbose/-v to also emit a compiler-style filename:1:1: info: linted successfully line (on stderr) for each file that lints cleanly.

Neovim Integration

To register tomllint with nvim-lint, you'd add something like this to your ~/.config/nvim/init.lua or other imported file.

require("lint").linters_by_ft.toml = { "tomllint" }
local function parse_tomllint_output(output, bufnr, _linter_cwd)
	local diagnostics = {}
	for line in output:gmatch("[^\r\n]+") do
		local _, lnum, col, description = line:match("(.+):(%d+):(%d+): error: (.+)")
		if lnum and description then
			table.insert(diagnostics, {
				bufnr = bufnr,
				lnum = tonumber(lnum) - 1,
				col = tonumber(col) - 1,
				end_lnum = tonumber(lnum) - 1,
				end_col = tonumber(col),
				severity = vim.diagnostic.severity.ERROR,
				message = description,
			})
		end
	end
	return diagnostics
end
require("lint").linters.tomllint = {
	cmd = "tomllint",
	stdin = true,
	append_fname = false,
	args = { "-" },
	stream = "stderr",
	ignore_exitcode = false,
	env = nil,
	parser = parse_tomllint_output,
}

Pickls Integration

Pickls is a unified LSP that integrates command-line linters and formatters with editors like Neovim and Zed. Add the following to your ~/.config/pickls/pickls.yaml:

languages:
  toml:
    linters:
      - program: tomllint
        args: ["-"]
        pattern: '(.*):(\d+):(\d+): error: (.*)'
        line_match: 2
        start_col_match: 3
        description_match: 4
        use_stderr: true
        use_stdin: true

pre-commit Integration

pre-commit is a framework for managing and maintaining multi-language pre-commit hooks. To use tomllint to check your files when doing a git commit, add this to your .pre-commit-config.yaml:

repos:
  - repo: https://github.com/wbbradley/tomllint
    rev: v0.3.5
    hooks:
      - id: tomllint

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tomllint-0.3.5.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tomllint-0.3.5-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file tomllint-0.3.5.tar.gz.

File metadata

  • Download URL: tomllint-0.3.5.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for tomllint-0.3.5.tar.gz
Algorithm Hash digest
SHA256 5f94d3c091c6fb70d98cc46608626843cc00094a8e88983f0a491730933b9846
MD5 ad772e7f62995dc461d4b1af91998fb7
BLAKE2b-256 06441f37b486306b3823df4baeac7a4cfb811c59f141327b277e7cf894ed226c

See more details on using hashes here.

File details

Details for the file tomllint-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: tomllint-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for tomllint-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 86f564bafd6878a44e75a25a087b457cbe27e5792ce97566b8bbf3ede28864ee
MD5 455e08da411ba976fb5aa23f4f8e2d38
BLAKE2b-256 f7b88d67bbaab71224872deec0c8fddf0d73fa0087ddeffc11d196e8d84a6cbd

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.6

2 files

This release

0.3.5 This release

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page