--- title: transform.Remarshal description: Returns a string of serialized data in the specified format, marshaled from a string of serialized data or a map. categories: [] keywords: [] params: functions_and_methods: aliases: [] returnType: string signatures: [transform.Remarshal FORMAT INPUT] aliases: [/functions/transform.remarshal] --- ## Usage The format must be one of `json`, `toml`, `yaml`, or `xml`. If the input is a string of serialized data, it must be valid JSON, TOML, YAML, or XML. > [!NOTE] > This function is primarily a helper for Hugo's documentation, used to convert configuration and front matter examples to JSON, TOML, and YAML. > > This is not a general purpose converter, and may change without notice if required for Hugo's documentation site. ## Examples The following examples convert data from one serialized format to another. ### TOML to JSON This example converts a string of TOML to JSON: ```go-html-template {{ $s := ` baseURL = 'https://example.org/' locale = 'en-US' title = 'ABC Widgets' `}}
{{ transform.Remarshal "json" $s }}
```
Resulting HTML:
```html
{
"baseURL": "https://example.org/",
"locale": "en-US",
"title": "ABC Widgets"
}
```
Rendered in browser:
```text
{
"baseURL": "https://example.org/",
"locale": "en-US",
"title": "ABC Widgets"
}
```
### Map to YAML
This example converts a map to YAML:
```go-html-template
{{ $m := dict
"a" "Hugo rocks!"
"b" (dict "question" "What is 6x7?" "answer" 42)
"c" (slice "foo" "bar")
}}
{{ transform.Remarshal "yaml" $m }}
```
Resulting HTML:
```html
a: Hugo rocks! b: answer: 42 question: What is 6x7? c: - foo - bar``` Rendered in browser: ```text a: Hugo rocks! b: answer: 42 question: What is 6x7? c: - foo - bar ```