TOML support #42

Open
opened 2025-12-30 01:19:51 +01:00 by adam · 6 comments
Owner

Originally created by @padhia on GitHub (Feb 7, 2024).

Hi, just came here to check Pkl out. Unless it's hidden somewhere, I didn't see TOML being supported as an output format. Would it be possible to add TOML support?

Thanks!

Originally created by @padhia on GitHub (Feb 7, 2024). Hi, just came here to check Pkl out. Unless it's hidden somewhere, I didn't see TOML being supported as an output format. Would it be possible to add TOML support? Thanks!
Author
Owner

@bioball commented on GitHub (Feb 7, 2024):

Hi, at the moment, TOML support is implemented via a package, rather than in the standard library.

https://pkl-lang.org/package-docs/pkg.pkl-lang.org/pkl-pantry/pkl.toml/current/index.html

You can render TOML via:

import "package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.0#/toml.pkl"

output {
  renderer = new toml.Renderer {}
}
@bioball commented on GitHub (Feb 7, 2024): Hi, at the moment, TOML support is implemented via a package, rather than in the standard library. https://pkl-lang.org/package-docs/pkg.pkl-lang.org/pkl-pantry/pkl.toml/current/index.html You can render TOML via: ```groovy import "package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.0#/toml.pkl" output { renderer = new toml.Renderer {} } ```
Author
Owner

@padhia commented on GitHub (Feb 7, 2024):

Thank you for the link. Please consider adding TOML to a future version of the CLI to make generating TOML files easier.

@padhia commented on GitHub (Feb 7, 2024): Thank you for the link. Please consider adding TOML to a future version of the CLI to make generating TOML files easier.
Author
Owner

@zaxebo1 commented on GitHub (Feb 12, 2024):

toml is extremely popular configuration/interchange format. Kindly do consider it adding it in the mainstream code

@zaxebo1 commented on GitHub (Feb 12, 2024): toml is extremely popular configuration/interchange format. Kindly do consider it adding it in the mainstream code
Author
Owner

@bioball commented on GitHub (Feb 23, 2024):

We're working on it!

@bioball commented on GitHub (Feb 23, 2024): We're working on it!
Author
Owner

@brimworks commented on GitHub (Jul 10, 2025):

Any updates on supporting TOML? Our team is a bit weary of downloading arbitrary code off the internet just to get toml support.

@brimworks commented on GitHub (Jul 10, 2025): Any updates on supporting TOML? Our team is a bit weary of downloading arbitrary code off the internet just to get toml support.
Author
Owner

@bioball commented on GitHub (Jul 10, 2025):

pkl.toml is a package that you can include as a dependency in a project. This means that its integrity is verified whenever it is downloaded, and can also vendor inside your repo (by setting the cache dir to a local relative path).

To use toml as a dependency, your PklProject should have:

amends "pkl:Project"

dependencies {
  ["toml"] { 
    uri = "package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.2"
  }
}

You'll then want to run pkl project resolve to create a PklProject.deps.json file in the same folder. Once you have that, you can import toml using dependency notation:

import "@toml/toml.pkl"

Or, if you don't want to use projects for some reason, you can also specify the SHA checksum as part of the import itself:

import "package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.2::sha256:45fea4cf14e7d776e131b338efe2a7016f86c87b0c0f532409f728033bd82f71#/toml.pkl"

All this to say: you shouldn't need to be concerned about the TOML package as coming from the internet.

@bioball commented on GitHub (Jul 10, 2025): `pkl.toml` is a package that you can include as a dependency in a [project](https://pkl-lang.org/main/current/language-reference/index.html#project-dependencies). This means that its integrity is verified whenever it is downloaded, and can also vendor inside your repo (by setting the cache dir to a local relative path). To use toml as a dependency, your PklProject should have: ```pkl amends "pkl:Project" dependencies { ["toml"] { uri = "package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.2" } } ``` You'll then want to run `pkl project resolve` to create a `PklProject.deps.json` file in the same folder. Once you have that, you can import toml using dependency notation: ```pkl import "@toml/toml.pkl" ``` Or, if you don't want to use projects for some reason, you can also specify the SHA checksum as part of the import itself: ```pkl import "package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.2::sha256:45fea4cf14e7d776e131b338efe2a7016f86c87b0c0f532409f728033bd82f71#/toml.pkl" ``` All this to say: you shouldn't need to be concerned about the TOML package as coming from the internet.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#42