All Tools View Categories About Contact Privacy

IAM Policy YAML to JSON Converter

Convert a YAML-formatted IAM policy block (CloudFormation/Terraform style) into JSON.

Supports the practical YAML subset used by policy documents — not a full YAML 1.2 parser. Runs entirely in your browser.

  

About IAM Policy YAML to JSON Converter

CloudFormation templates are frequently written in YAML, and an AWS::IAM::Policy or AWS::IAM::ManagedPolicy resource's PolicyDocument: block is written in that same YAML — not JSON — even though IAM itself only ever evaluates JSON. IAM Policy YAML to JSON Converter takes that YAML-formatted policy block and converts it into the equivalent JSON document, so you can test it in the IAM Policy Simulator, paste it into the AWS CLI, or compare it against a JSON policy from elsewhere.

This is a hand-written, practical-subset parser, not a full implementation of the YAML 1.2 specification. It covers exactly what typical policy YAML uses: nested block mappings, block sequences — including the very common "sequence of mappings" shape where each Statement list item is itself a small mapping (- Effect: Allow followed by indented Action:, Resource:, etc.) — inline flow sequences like [s3:GetObject, s3:PutObject], inline flow mappings like {Effect: Allow, Action: "*"}, quoted and bare scalar strings, and # comments. It deliberately does not attempt anchors/aliases, multi-document streams, block scalar styles, or other advanced YAML features that essentially never appear in an IAM policy block — if your YAML uses one of those, the conversion is not guaranteed to work and you should fall back to a general-purpose YAML tool.

Because getting this wrong silently would be worse than not converting at all, a parse failure always surfaces as a clear error naming the problem — it never falls back to guessing and producing plausible-looking but incorrect JSON.

Features

  • Converts YAML policy blocks to JSON, covering block mappings, block sequences, sequences of mappings, and inline flow syntax.
  • Handles quoted and bare scalars, comments, and blank lines.
  • Clear parse errors instead of silently wrong output on unsupported syntax.
  • Structural IAM validation of the resulting JSON, with a warning if incomplete.
  • Pretty-printed JSON output with one-click copy.
  • Sample multi-statement YAML to try instantly.
  • 100% client-side — nothing is uploaded.

How to Use

  1. Paste the YAML policy block (e.g. copied out of a CloudFormation PolicyDocument: section), or click the sample.
  2. Click Convert to JSON.
  3. Review any parse error if conversion failed — it names the problem line.
  4. Copy the resulting JSON with the copy button.

Examples

Example 1 — typical CFN-style block. A Version:/Statement: mapping with a sequence of statement mappings, each with nested Action:/Resource: lists, converts cleanly to the equivalent JSON.

Example 2 — inline flow syntax. Action: [s3:GetObject, s3:PutObject] converts to a JSON array the same as the multi-line block-sequence form would.

Example 3 — nested Condition. A Condition: mapping with a Bool: child mapping containing aws:SecureTransport: "true" converts to the matching nested JSON object.

Example 4 — unsupported feature. YAML using an anchor (&base) or a literal block scalar (|) produces a clear error rather than wrong output.

Benefits

  • Skips the manual reformatting of copying a CFN YAML policy block into JSON by hand.
  • Fails loudly on unsupported YAML instead of silently producing incorrect JSON.
  • Flags structurally incomplete results so you know if the converted policy is missing required fields.
  • Private — parsing runs entirely in your browser.

Frequently Asked Questions

What subset of YAML does this actually support?
Only what typical IAM policy blocks embedded in CloudFormation templates or Terraform heredocs use: block mappings (<code>key:</code> with indented children), block sequences including sequences of mappings (the common <code>- Effect: Allow</code> list-item shape), inline flow sequences <code>[a, b, c]</code>, inline flow mappings <code>{key: value}</code>, single/double-quoted and bare scalar strings, and <code>#</code> comments. That is deliberately a narrow, bounded subset.
What YAML features are NOT supported?
This is not a general-purpose YAML 1.2 parser. It does not support anchors/aliases (<code>&anchor</code> / <code>*alias</code>), multi-document streams, block scalar styles (<code>|</code> literal or <code>&gt;</code> folded), explicit type tags, merge keys, or any other advanced YAML feature. If your YAML uses any of those, parsing will fail or produce wrong output — stick to the plain nested-mapping/sequence style shown in the sample.
What happens if the YAML cannot be parsed?
You get a clear error rather than a silently wrong JSON document — either a specific "unexpected content" message naming the offending line, or a JavaScript exception message if something inside a flow sequence/mapping was malformed. The tool never guesses past a parse failure.
Is the resulting JSON validated as an IAM policy?
Yes — after parsing succeeds, the result is run through the same structural validator used across this tool suite (checks for <code>Version</code>, non-empty <code>Statement</code>, and required per-statement fields), and a warning is shown if the parsed document does not look like a complete IAM policy, without blocking you from seeing the converted JSON.
Why would I need this instead of a general YAML-to-JSON converter?
General YAML-to-JSON tools work fine too. This one exists in-context for the common case of copying an IAM policy statement block out of a CloudFormation <code>PolicyDocument:</code> section (which is written in YAML when the template itself is YAML) and getting straight to JSON, without needing a separate general-purpose tool.
Is my YAML uploaded anywhere?
No — parsing happens entirely in your browser.