Ansible Vault decrypt and encrypt

Runs in your browser

Paste a vault file or a YAML file with !vault | variables and the vault password. Every variable is decrypted at once. Nothing leaves your browser.

Waiting for input

Paste a vault file and the password

A whole file from ansible-vault encrypt, or a YAML file with name: !vault | variables. hiera-eyaml values and Chef data bags work too.

Examples

Start from an example

Each example fills in the tool above and decrypts it. All keys and passwords are demo values made for this page.

The format

How a vault file is built

A vault starts with a header line, then hex. Inside the hex are three lines of hex again: salt, HMAC and the encrypted data.

PartWhat it is
$ANSIBLE_VAULT;1.1;AES256Format 1.1; 1.2 adds the vault ID: $ANSIBLE_VAULT;1.2;AES256;prod
Salt32 random bytes
KeysPBKDF2-HMAC-SHA256 with 10,000 rounds: 32 bytes for AES, 32 for the HMAC, 16 for the counter
HMAC-SHA256Over the encrypted data. A wrong password is detected before anything is decrypted.
DataAES-256-CTR, padded with PKCS#7

For variables, ansible-vault encrypt_string writes the same block, indented under name: !vault |. The tool finds all of them in a vars file and shows the file with the values in plain text.

In your terminal

The same with ansible-vault

Show a file
ansible-vault view group_vars/all/vault.yml
ansible-vault decrypt --output - group_vars/all/vault.yml
One variable
ansible localhost -m debug -a var=db_password -e @group_vars/all/vars.yml --ask-vault-pass
Encrypt a string
ansible-vault encrypt_string --name db_password 's3cr3t'
ansible-vault encrypt_string --vault-id prod@prompt --name api_token 'tok-123'
Change password
ansible-vault rekey group_vars/all/vault.yml
Common errors

When ansible-vault refuses

Decryption failed (no vault secrets were found that could decrypt)

Wrong password, or the file needs a different vault ID. With several vault IDs, each variable may need its own password.

Indentation in vars files

The hex lines under !vault | must be indented evenly. Copied from a chat or a web page, they often aren’t; the tool tolerates it, Ansible doesn’t.

A newline in the value

encrypt_string from stdin includes the final newline. Use --stdin-name and printf, or check the decrypted value here.

Format 1.0 (AES)

Files from Ansible 1.x use plain AES (no AES256). Current Ansible can’t open them anymore.

Also on this page

hiera-eyaml and Chef data bags

hiera-eyaml (Puppet) writes ENC[PKCS7,…]: CMS with RSA key transport and AES-256-CBC. Paste values or a whole Hiera file and the private key keys/private_key.pkcs7.pem. Encrypting needs the certificate public_key.pkcs7.pem.

Chef encrypted data bags store each field as encrypted_data, iv and cipher (version 1 and 2: AES-256-CBC, version 3: AES-256-GCM). Paste the item as JSON (knife data bag show BAG ITEM -F json) and the secret from encrypted_data_bag_secret.

Under the hood

Tested against the original tools

Every format on this page was checked against values made by the real tool, on 3 December 2026:

  • Vault files and encrypt_string variables made by ansible-vault (ansible-core 2.20), with and without vault ID, wrong passwords. What the tool encrypts, ansible-vault decrypts.
  • hiera-eyaml: CMS from OpenSSL with AES-256 (the same call eyaml makes in Ruby), keys in PKCS#1 and PKCS#8; what the tool encrypts, OpenSSL and Ruby decrypt.
  • Chef: data bag items version 1, 2 and 3 made with Ruby’s OpenSSL as in Chef’s encryptor.
More formats

Other encrypted formats

Every format has its own page with the same tool. Paste anything into one of them: if it belongs elsewhere, the tool says so and takes it there.

FAQ

Questions about Ansible Vault

How do I decrypt an Ansible Vault string?

Paste the vars file (or just the name: !vault | block) above and enter the vault password. In a terminal: ansible-vault view for files, or the debug module for a single variable.

Can I decrypt it without the password?

No. The HMAC check fails, and AES-256 can’t be guessed. If the password itself is weak, it can be guessed, which is why vault passwords should be long and random.

What is a vault ID?

A label (like prod or dev) for one of several vault passwords. Format 1.2 writes it into the header so Ansible knows which password to try first. It doesn’t change the encryption.

Is the variable name encrypted?

No, only the value. Anyone with the file sees which variables exist.

Is it safe to paste a vault here?

Everything runs in your browser: nothing you paste is sent anywhere, not even to this site. The page’s Content-Security-Policy blocks connections to other sites; check the Network tab of your browser’s developer tools.

Searches the list of pages on this site. What you type stays in your browser.