# perldoc > YAML::XS

---
type: CommandReference
command: YAML::XS
mode: perldoc
section: 
source: perldoc
---

## Quick Reference

- `Dump @data` — serialize Perl data structure to YAML string
- `Load $yaml` — deserialize YAML string to Perl data structure
- `DumpFile $file, @data` — write YAML to file
- `LoadFile $file` — read YAML from file
- `$YAML::XS::LoadBlessed = 0` — disable object loading for security (safe load)
- `$YAML::XS::Boolean = "JSON::PP"` — enable boolean object support for "true"/"false"

## Name

Perl YAML Serialization using XS and libyaml

## Synopsis

perl
use YAML::XS;

my $yaml = Dump [ 1..4 ];
my $array = Load $yaml;
## Description

This module is a Perl XS binding to Kirill Simonov's `libyaml` (YAML 1.1 specification). It exports `Dump`, `Load`, `DumpFile` and `LoadFile` by default. These functions are intended to work exactly like `YAML.pm`'s corresponding functions.

**Unicode handling**: `YAML::XS` only deals with streams of utf8 octets. Remember:

perl
$perl = Load($utf8_octets);
$utf8_octets = Dump($perl);
## Options

- `$YAML::XS::LoadBlessed` (default: false) — When set to true, loads data as objects. When false, silently ignores tags and loads unblessed (safe load). Setting to false is recommended for untrusted YAML.
- `$YAML::XS::UseCode`, `$YAML::XS::DumpCode`, `$YAML::XS::LoadCode` — Enable deparsing and evaling of code blocks. Support for loading code added in v0.75.
- `$YAML::XS::QuoteNumericStrings` (default: true) — Quote strings that look like numbers to preserve formatting (e.g., leading zeros).
- `$YAML::XS::Boolean` (default: undef) — Set to `"JSON::PP"` or `"boolean"` to load plain `true`/`false` as JSON::PP::Boolean or boolean.pm objects, which are dumped again as plain `true`/`false`.
- `$YAML::XS::Indent` (default: 2) — Number of spaces for indentation in `Dump`.

## Examples

**Loading with boolean support**:

perl
local $YAML::XS::Boolean = "JSON::PP"; # or "boolean"
my $data = Load("booltrue: true");
$data->{boolfalse} = JSON::PP::false;
my $yaml = Dump($data);
# boolfalse: false
# booltrue: true
**Checking libyaml version** (since v0.79):

perl
my $libyaml_version = YAML::XS::LibYAML::libyaml_version();
## See Also

- [YAML](https://perldoc.perl.org/YAML) (YAML.pm)
- [YAML::Syck](https://perldoc.perl.org/YAML::Syck)
- [YAML::Tiny](https://perldoc.perl.org/YAML::Tiny)
- [YAML::PP](https://perldoc.perl.org/YAML::PP)
- [YAML::PP::LibYAML](https://perldoc.perl.org/YAML::PP::LibYAML)