{"id":455,"library":"toml","title":"TOML","description":"A Python library for parsing and creating TOML (Tom's Obvious, Minimal Language) files. Current version: 0.10.2. Maintained with regular updates.","status":"active","version":"0.10.2","language":"python","source_language":"en","source_url":"https://github.com/uiri/toml","tags":["TOML","configuration","parsing","Python"],"install":[{"cmd":"pip install toml","lang":"bash","label":"Install TOML"}],"dependencies":[],"imports":[{"note":"Ensure 'toml' is imported before using 'loads' function.","symbol":"loads","correct":"import toml\nparsed_toml = toml.loads(toml_string)"},{"note":"Ensure 'toml' is imported before using 'dumps' function.","symbol":"dumps","correct":"import toml\nnew_toml_string = toml.dumps(parsed_toml)"},{"note":"Ensure 'toml' is imported before using 'dump' function.","symbol":"dump","correct":"import toml\nwith open('new_toml_file.toml', 'w') as f:\n    toml.dump(parsed_toml, f)"}],"quickstart":{"code":"import toml\n\ntoml_string = '''\n# This is a TOML document.\n\ntitle = \"TOML Example\"\n\n[owner]\nname = \"Tom Preston-Werner\"\ndob = 1979-05-27T07:32:00-08:00 # First class dates\n\n[database]\nserver = \"192.168.1.1\"\nports = [ 8001, 8001, 8002 ]\nconnection_max = 5000\nenabled = true\n\n[servers]\n\n  # Indentation (tabs and/or spaces) is allowed but not required\n  [servers.alpha]\nip = \"10.0.0.1\"\ndc = \"eqdc10\"\n\n  [servers.beta]\nip = \"10.0.0.2\"\ndc = \"eqdc10\"\n\n[clients]\ndata = [ [\"gamma\", \"delta\"], [1, 2] ]\n\n# Line breaks are OK when inside arrays\nhosts = [\n  \"alpha\",\n  \"omega\"\n]\n'''\n\nparsed_toml = toml.loads(toml_string)\n\nnew_toml_string = toml.dumps(parsed_toml)\nprint(new_toml_string)","lang":"python","description":"A comprehensive example demonstrating parsing and generating TOML data using the 'toml' library."},"warnings":[{"fix":"Replace 'load' with 'loads' for strings and 'load' for file objects.","message":"In version 0.10.0, the 'load' function was removed. Use 'loads' for strings and 'load' for file objects.","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"Always import 'toml' at the beginning of your script.","message":"Ensure 'toml' is imported before using its functions like 'loads', 'dumps', and 'dump'.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-12T13:56:05.296Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Run `pip install toml` in your terminal to install the library.","cause":"The 'toml' package is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'toml'"},{"fix":"Review and correct the TOML file syntax according to the TOML specification, paying close attention to the indicated line and column.","cause":"The TOML file contains a syntax error at the specified line and column, such as an invalid character, missing quotes, or incorrect structure.","error":"toml.decoder.TomlParsingError: Unexpected character at line X column Y"},{"fix":"Ensure each key within a TOML table is unique; remove or rename duplicate keys to comply with the TOML standard.","cause":"A TOML file contains the same key defined multiple times within the same table, which is not allowed by the TOML specification.","error":"toml.decoder.TomlParsingError: Duplicate key 'keyname'"},{"fix":"Convert the unsupported Python object type to a TOML-compatible type (e.g., list, string, integer, float, boolean, datetime) before attempting to dump it to a TOML file.","cause":"The `toml.dump()` function was called with a Python object containing a type (e.g., set) that does not have a direct equivalent in the TOML specification.","error":"TypeError: Value for key 'x' of type <class 'set'> is not a TOML-supported type."}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.5,"disk_size":"17.9M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.5,"disk_size":"18M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.7,"disk_size":"19.8M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.7,"disk_size":"20M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.3,"disk_size":"11.6M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.3,"disk_size":"12M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.5,"disk_size":"11.3M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.3,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.3,"disk_size":"17.4M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.3,"disk_size":"18M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}