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.