AWS CloudFormation Template Converter

CloudFormation JSON to YAML

Convert AWS CloudFormation templates from JSON to YAML format instantly. Preserves all resources, parameters, mappings, and intrinsic functions.

CloudFormation JSON
1206 chars
YAML Output
YAML output will appear here...

How to Convert CloudFormation JSON to YAML

Converting AWS CloudFormation templates from JSON to YAML is simple with our free converter. Paste your entire CloudFormation JSON template into the input field, and the tool generates a properly formatted YAML template that AWS CloudFormation accepts.

The conversion preserves every element of your infrastructure definition. Resources, parameters, outputs, conditions, mappings, and metadata all convert exactly. Intrinsic functions like !Ref, !GetAtt, !Sub, and !Join work correctly in the YAML output.

AWS CloudFormation supports both JSON and YAML template formats. You can deploy either format through the AWS Console, CLI, or SDK without modification.

Why Convert CloudFormation to YAML

Improved Readability

CloudFormation templates often contain hundreds of lines. YAML's indentation-based structure makes large templates easier to navigate without counting braces.

Add Comments

JSON doesn't support comments. YAML lets you document why resources exist, what values mean, and when things might change.

Shorter Intrinsic Functions

YAML supports shorthand syntax for CloudFormation functions. Use !Ref instead of {"Fn::Ref": ...}.

Easier Team Reviews

Infrastructure changes in pull requests are easier to review in YAML format. Cleaner syntax helps team members spot modifications.

Adding Comments to Document Infrastructure

YAML with Comments
Resources:
  # Primary application load balancer
  # Handles all incoming traffic from CloudFront
  ApplicationLoadBalancer:
    Type: AWS::ElasticLoadBalancingV2::LoadBalancer
    Properties:
      # Use internal scheme for private subnets
      Scheme: internal

Intrinsic Function Conversion

All CloudFormation intrinsic functions convert with proper YAML syntax:

JSON SyntaxYAML Short FormYAML Full Form
{"Ref": "X"}!Ref XRef: X
{"Fn::GetAtt": ["X", "Y"]}!GetAtt X.YFn::GetAtt: [X, Y]
{"Fn::Sub": "..."}!Sub '...'Fn::Sub: '...'
{"Fn::Join": [...]}!Join [...]Fn::Join: [...]
{"Fn::If": [...]}!If [...]Fn::If: [...]
{"Fn::ImportValue": "..."}!ImportValue ...Fn::ImportValue: ...

Supported CloudFormation Elements

All CloudFormation template sections convert:

  • AWSTemplateFormatVersion Template version declaration
  • Description Template description text
  • Metadata Template metadata including AWS::CloudFormation::Interface
  • Parameters Input parameters with types and constraints
  • Mappings Lookup tables for conditional values
  • Conditions Conditional logic definitions
  • Transform Macros and SAM transforms
  • Resources Infrastructure resource definitions
  • Outputs Stack output values

CloudFormation YAML Best Practices

Organize Related Resources

Group related resources together with comment headers:

Organized Resources
Resources:
  # ===================================
  # Networking Resources
  # ===================================

  VPC:
    Type: AWS::EC2::VPC
    # ...

  PublicSubnet:
    Type: AWS::EC2::Subnet
    # ...

  # ===================================
  # Compute Resources
  # ===================================

  WebServer:
    Type: AWS::EC2::Instance
    # ...

Use YAML Anchors for Repeated Values

YAML anchors reduce duplication in templates:

YAML Anchors
Parameters:
  Environment:
    Type: String
    Default: &defaultEnv production  # Define anchor

Resources:
  MyBucket:
    Type: AWS::S3::Bucket
    Properties:
      Tags:
        - Key: Environment
          Value: *defaultEnv  # Reference anchor

CloudFormation Conversion Example

Input: JSON Template

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "Simple S3 bucket",
  "Parameters": {
    "BucketName": {
      "Type": "String"
    }
  },
  "Resources": {
    "MyBucket": {
      "Type": "AWS::S3::Bucket",
      "Properties": {
        "BucketName": {"Ref": "BucketName"}
      }
    }
  },
  "Outputs": {
    "BucketArn": {
      "Value": {"Fn::GetAtt": ["MyBucket", "Arn"]}
    }
  }
}

Output: YAML Template

AWSTemplateFormatVersion: '2010-09-09'
Description: Simple S3 bucket

Parameters:
  BucketName:
    Type: String

Resources:
  MyBucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: !Ref BucketName

Outputs:
  BucketArn:
    Value: !GetAtt MyBucket.Arn

Frequently Asked Questions

Does AWS CloudFormation support both JSON and YAML?

Yes. AWS CloudFormation accepts templates in either JSON or YAML format. Both formats are fully supported through the Console, CLI, SDK, and CloudFormation APIs.

Are intrinsic functions converted correctly?

Yes. Intrinsic functions like Ref, Fn::GetAtt, Fn::Sub, Fn::Join, and all others convert to their YAML equivalents. You can use either the short form (!Ref) or long form (Ref:) in YAML.

Can I use the YAML template with AWS SAM?

Yes. AWS SAM (Serverless Application Model) templates use CloudFormation syntax and support YAML format. The converter handles SAM-specific transforms and resource types correctly.

Are nested stacks supported?

Yes. Nested stack references and AWS::CloudFormation::Stack resources convert normally. Template URLs and parameters maintain their values.

What about CloudFormation macros?

Transform declarations for AWS::Include, AWS::Serverless, and custom macros convert correctly. The Transform section maintains its structure in YAML.

Is the conversion reversible?

Yes. You can convert JSON to YAML and back to JSON without losing information. The data structure remains identical in both formats.

Can I convert very large templates?

Yes. The converter runs in your browser and handles templates of any size that your browser's memory can process. CloudFormation templates up to the 1MB AWS limit convert without issues.

Related Tools