Title: Python and TOML: Read, Write, and Configure with tomllib – Real Python
Open Graph Title: Python and TOML: Read, Write, and Configure with tomllib – Real Python
Description: Learn how to read, write, and manage TOML files in Python using tomllib and tomli. Parse config data, validate settings, and support pyproject.toml.
Open Graph Description: Learn how to read, write, and manage TOML files in Python using tomllib and tomli. Parse config data, validate settings, and support pyproject.toml.
Mail addresses
?subject=Python article for you&body=Python and TOML: Read, Write, and Configure with tomllib on Real Python
https://realpython.com/python-toml/
Opengraph URL: https://realpython.com/python-toml/
X: @realpython
Domain: realpython.com
{
"@context": "http://schema.org",
"@type": "Article",
"headline": "Python and TOML: Read, Write, and Configure with tomllib",
"image": {
"@type": "ImageObject",
"url": "https://files.realpython.com/media/TOML-in-Python_Watermarked.1bca2ba00140.jpg",
"width": 1920,
"height": 1080
},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://realpython.com/python-toml/",
"lastReviewed": "2025-01-25",
"author": {
"@type": "Person",
"name": "Geir Arne Hjelle",
"image": "https://realpython.com/cdn-cgi/image/width=800,height=800,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/gahjelle.470149ee709e.jpg",
"url": "https://realpython.com/team/gahjelle/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
"reviewedBy": [
{
"@type": "Person",
"name": "Aldren Santos",
"image": "https://realpython.com/cdn-cgi/image/width=500,height=500,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Aldren_Santos_Real_Python.6b0861d8b841.png",
"url": "https://realpython.com/team/asantos/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
{
"@type": "Person",
"name": "Brenda Weleschuk",
"image": "https://realpython.com/cdn-cgi/image/width=320,height=320,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/IMG_3324_1.50b309355fc1.jpg",
"url": "https://realpython.com/team/bweleschuk/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
{
"@type": "Person",
"name": "Bartosz Zaczy\u0144ski",
"image": "https://realpython.com/cdn-cgi/image/width=1694,height=1694,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/coders_lab_2109368.259b1599fbee.jpg",
"url": "https://realpython.com/team/bzaczynski/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
{
"@type": "Person",
"name": "Kate Finegan",
"image": "https://realpython.com/cdn-cgi/image/width=400,height=400,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/VZxEtUor_400x400.7169c68e3950.jpg",
"url": "https://realpython.com/team/kfinegan/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
{
"@type": "Person",
"name": "Philipp Acsany",
"image": "https://realpython.com/cdn-cgi/image/width=400,height=400,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/phi5_2.0e61b4c66f6b.jpg",
"url": "https://realpython.com/team/pacsany/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
}
]
},
"datePublished": "2025-01-25T14:00:00+00:00",
"dateModified": "2025-01-25T14:09:16.418923+00:00",
"publisher": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": {
"@type": "ImageObject",
"url": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png",
"width": 512,
"height": 512
},
"description": "Real Python is a leading provider of online Python education and one of the largest language-specific online communities for software developers. It publishes high-quality learning resources, such as tutorials, books, and courses to an audience of millions of developers, data scientists, and machine learning engineers each month.",
"slogan": "Become a Python Expert",
"email": "info@realpython.com",
"sameAs": [
"https://github.com/realpython",
"https://www.youtube.com/realpython",
"https://twitter.com/realpython",
"https://x.com/realpython",
"https://www.linkedin.com/company/realpython-com/",
"https://www.facebook.com/learnrealpython",
"https://www.instagram.com/realpython",
"https://www.tiktok.com/@realpython.com"
]
},
"author": {
"@type": "Person",
"name": "Geir Arne Hjelle",
"image": "https://realpython.com/cdn-cgi/image/width=800,height=800,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/gahjelle.470149ee709e.jpg",
"url": "https://realpython.com/team/gahjelle/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
"description": "Learn how to read, write, and manage TOML files in Python using tomllib and tomli. Parse config data, validate settings, and support pyproject.toml.",
"hasPart": {
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "What is TOML in Python?",
"acceptedAnswer": {
"@type": "Answer",
"text": "TOML—Tom’s Obvious Minimal Language—is a reasonably new configuration file format that the Python community has embraced over the last couple of years. TOML is an essential part of the Python ecosystem.
"
}
},
{
"@type": "Question",
"name": "What is a TOML file used for?",
"acceptedAnswer": {
"@type": "Answer",
"text": "You use a TOML file to store configuration settings for applications, allowing you to change settings without modifying the source code. Many of your favorite tools rely on TOML for configuration, and you’ll use pyproject.toml when you build and distribute your own packages.
"
}
},
{
"@type": "Question",
"name": "What is the pyproject.toml file for?",
"acceptedAnswer": {
"@type": "Answer",
"text": "The pyproject.toml file is used in Python projects to specify build system requirements and configurations for various tools, such as package managers and linters.
"
}
},
{
"@type": "Question",
"name": "How do you load a TOML file in Python?",
"acceptedAnswer": {
"@type": "Answer",
"text": "You load a TOML file in Python using the tomli or tomllib module, which provides functions to parse the file into a Python dictionary.
"
}
},
{
"@type": "Question",
"name": "What is the difference between tomli and tomllib?",
"acceptedAnswer": {
"@type": "Answer",
"text": "tomli is a third-party library for parsing TOML files in Python, while tomllib is its counterpart added to the Python standard library starting from version 3.11.
"
}
}
]
}
}
| author | Real Python |
| twitter:card | summary_large_image |
| twitter:image | https://files.realpython.com/media/TOML-in-Python_Watermarked.1bca2ba00140.jpg |
| og:image | https://files.realpython.com/media/TOML-in-Python_Watermarked.1bca2ba00140.jpg |
| twitter:creator | @realpython |
| og:type | article |
Links:
Viewport: width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover
Robots: max-image-preview:large