Configuration#
The converter configuration holds settings that apply across all conversions: data access policy, fonts, plugins, worker resources, and default themes and locales. Values such as output format, dimensions, and scale belong to the individual conversion instead. See Conversion Overrides for those.
JSONC Configuration Files#
Python, Rust, the CLI, and the server all read the same configuration format. This example limits worker resources and blocks external data and image loads. Save it as production.vlc.jsonc:
production.vlc.jsonc
{
// Persistent conversion workers
"num_workers": 4,
// Data loading
"base_url": false,
"allowed_base_urls": [],
// Fonts
"auto_google_fonts": false,
"google_fonts": [
{"family": "Inter", "variants": [{"weight": 400, "style": "normal"}]}
],
"missing_fonts": "warn",
// JavaScript resource limits
"max_v8_heap_size_mb": 1024,
"max_v8_execution_time_secs": 10,
// Vega extensions
"vega_plugins": [],
"plugin_import_domains": [],
// Vega-Lite defaults
"default_theme": null,
"default_format_locale": null,
"default_time_format_locale": null
}
Note that JSONC is JSON with support for comments and trailing commas.
Fields omitted from the file use their built-in defaults. This example changes some of those defaults: base_url normally points at the Vega datasets CDN, and allowed_base_urls permits any HTTP or HTTPS URL. Setting base_url to false rejects relative data and image URLs. Setting allowed_base_urls to an empty list rejects every external URL and local file.
allowed_base_urls accepts Content Security Policy-style patterns. Grant only the paths, URL prefixes, or schemes the application needs, and use "*" only when every input is trusted. See Security and Network Access.
Configure a Rust Converter#
Load the file with VlcConfig::from_file(), update its fields, then pass it to VlConverter::with_config(). This example changes the worker count from 4 to 2:
use std::num::NonZeroU64;
use std::path::Path;
use vl_convert_rs::{VlcConfig, VlConverter};
let mut config = VlcConfig::from_file(Path::new("production.vlc.jsonc"))?;
config.num_workers = NonZeroU64::new(2).unwrap();
let converter = VlConverter::with_config(config)?;
To configure without a file, start with VlcConfig::default(). The converter keeps its settings for its lifetime. See Rust Converter Lifecycle for sharing and reusing it.