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: name one or more files to lint, or use - as the sole filename to 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.

Release artifacts include a tomllint(1) manual page. System package installations and modern pipx installations expose it through man tomllint. A virtual-environment installation places it under that environment's share/man/man1, which may not be on MANPATH.

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.6
    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.6.tar.gz (6.8 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.6-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tomllint-0.3.6.tar.gz
  • Upload date:
  • Size: 6.8 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.6.tar.gz
Algorithm Hash digest
SHA256 7ed5d87862ba133d72a6b9590fe85445d24008c13629e71f05fbbba8693c786b
MD5 f5b881a681203b63b2326b3f7d056e62
BLAKE2b-256 0c7be5557c8434153ec351a927498103d220e0f4985fe1e8f3f93a2dab71310f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tomllint-0.3.6-py3-none-any.whl
  • Upload date:
  • Size: 5.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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 76d6d592b4764a25ff3da6f08a2c073d43618ecc98dd3baf198094c7b10db5a1
MD5 4059f03f9f4e824126af762fd9f790e5
BLAKE2b-256 5fac6acc186db7d697c14678d5eb511d771082d5ae4f284811927f7d246faeb1

See more details on using hashes here.

Supported by

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