Type: Package
Title: Read, Write, and Modify TOML Files
Version: 1.0.0
Description: Simple toolkit for working with TOML text. Based on tomledit which allows for modifying TOML while preserving order, comments,and whitespace.
License: MIT + file LICENSE
Encoding: UTF-8
Imports: jsonlite, V8 (≥ 8.0.0)
BugReports: https://github.com/jeroen/toml/issues
RoxygenNote: 7.3.2
NeedsCompilation: no
Packaged: 2025-10-10 22:29:17 UTC; jeroen
Author: Jeroen Ooms [aut, cre]
Maintainer: Jeroen Ooms <jeroenooms@gmail.com>
Repository: CRAN
Date/Publication: 2025-10-16 18:10:02 UTC

Parse or Edit TOML text

Description

The edit_toml() function modifies values in a TOML text while retaining the order, comments, and whitespace. Use read_toml() and write_toml() to convert between TOML text and R lists.

Usage

read_toml(file, as_json = FALSE)

parse_toml(toml, as_json = FALSE)

write_toml(x, auto_unbox = TRUE)

edit_toml(toml, field, value)

Arguments

file

path to file with toml text

as_json

return output as json string instead of R list

toml

string

x

vector or json string to convert to TOML

auto_unbox

convert atomic vectors of length 1 as scalars in TOML, unless they are wrapped in I(). See also jsonlite::toJSON.

field

name of field to change, for example package.version.

value

new value of field to set.

Value

parse_toml() returns a list and edit_toml() returns the modified TOML text.

References

toml-edit-js examples

Examples

toml <- readLines('https://raw.githubusercontent.com/posit-dev/air/refs/heads/main/Cargo.toml')
toml <- edit_toml(toml, 'workspace.package.rust-version', '1.84')
toml <- edit_toml(toml, 'workspace.dependencies.bla', list(path = "./yolo", rev = "123"))