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.4
    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.4.tar.gz (5.5 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.4-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tomllint-0.3.4.tar.gz
  • Upload date:
  • Size: 5.5 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.4.tar.gz
Algorithm Hash digest
SHA256 47f22d201266319a5be064b4f203fb9bb1efbbe40fd8337f8dcb118a4d62963c
MD5 a615485371f1e48a2238e93b1df8ac8e
BLAKE2b-256 df4265a8638bf1754684740c6a59143e91890b219ff0594a43372df869b64c7c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tomllint-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 4.7 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fb534acc71f5cd135546f1a128dd0f1970a91a3f4d645527cc0ed9e89621be3f
MD5 27654adf5aaac8ad26d8eb23436cdfc9
BLAKE2b-256 ed6cb7937fe4b73e682e586cb720324ef8882d1302fa5cade2bc8220563c4928

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.6

2 files

0.3.5

2 files

This release

0.3.4 This release

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