tauri-plugin-configurate lets you serialize your stored configuration to a plain string in JSON, YAML, or TOML format — regardless of which provider the config is stored in — and import it back from any of those formats. This is useful for configuration backup and restore flows, copy-paste sharing between users, developer tooling, and migrating configs across storage formats.
exportAs reads the current stored config and returns it as a formatted string. You choose the target format — "json", "yml", or "toml" — independently of the provider the config uses for storage.
If your schema contains keyring() fields and you want those secrets included in the export, pass a KeyringOptions object as the second argument. Without it, keyring fields appear as null in the output.
// Export as JSON — keyring fields will be null
const jsonStr = await config.exportAs("json");
// Export as YAML with secrets populated from the OS keyring
const yamlStr = await config.exportAs("yml", {
service: "my-app",
account: "default",
});
// Export as TOML
const tomlStr = await config.exportAs("toml");
exportAs returns a Promise<string>. The string is ready to write to a file, copy to the clipboard, or send over a network.
importFrom(content, format, keyringOpts?)
importFrom parses a config string and replaces the entire current stored config with the parsed data. It is a full replacement, not a merge — any keys present in storage but absent from the imported string will be removed.
Pass keyringOpts when the imported data contains values that should be written to the OS keyring. Without it, keyring fields in the string are stored as-is in the config file rather than being moved to the keyring.
// Import from a JSON string
await config.importFrom('{"theme": "dark"}', "json");
// Import YAML with keyring fields written to the OS keyring
await config.importFrom("theme: dark\n", "yml", {
service: "my-app",
account: "default",
});
// Import TOML
await config.importFrom('theme = "dark"\n', "toml");
importFrom returns Promise<void>. After it resolves, a subsequent config.load() will return the newly imported data.
| Format | format value | Notes |
|---|
| JSON | "json" | Pretty-printed, human-readable |
| YAML | "yml" | Human-readable, supports comments in source |
| TOML | "toml" | Human-readable; null values are omitted (no native TOML null) |
File size limit
To protect against runaway imports, the plugin enforces a maximum input size when parsing the content string. The default limit is 16 MiB.
You can raise or lower this limit in your Rust setup:
tauri_plugin_configurate::Builder::default()
.max_read_bytes(32 * 1024 * 1024) // 32 MiB
.build()
Or in tauri.conf.json:
{
"plugins": {
"configurate": {
"maxReadBytes": 33554432
}
}
}
When both tauri.conf.json and the Rust Builder set maxReadBytes, the value in tauri.conf.json takes precedence. Use tauri.conf.json when you need the limit to be adjustable per environment without recompiling.
Attempting to import a string larger than the configured limit throws an error before any parsing occurs.
Round-trip example
The following pattern exports a config, allows the user to edit the string, then imports the result back — a simple in-app config editor flow:
// 1. Export current config as JSON
const json = await config.exportAs("json");
// 2. Present json to the user for editing (e.g. in a textarea)
const edited = await openEditorDialog(json);
// 3. Import the edited string back
await config.importFrom(edited, "json");
// 4. Reload to get the updated data
const { data } = await config.load().run();
applySettings(data);
YAML supports anchor and alias expansion (&anchor / *alias), which can be abused in untrusted input to produce exponentially large objects (a “YAML bomb”). Only import YAML from sources you control. When accepting config strings from external or user-supplied input, prefer "json" or "toml" — neither format supports entity expansion.