Convert Terraform Backend Configuration to JSON

Convert Terraform backend blocks for state management including S3, GCS, Azure Blob, and Consul backends from HCL to JSON.

Advanced

Detailed Explanation

Terraform Backend Configuration

Backend blocks configure where Terraform stores its state file. The backend is specified within the terraform block and supports various storage providers.

S3 Backend (AWS)

terraform {
  backend "s3" {
    bucket         = "my-terraform-state"
    key            = "production/terraform.tfstate"
    region         = "us-east-1"
    dynamodb_table = "terraform-locks"
    encrypt        = true
  }
}

JSON Equivalent

{
  "terraform": {
    "backend": {
      "s3": {
        "bucket": "my-terraform-state",
        "key": "production/terraform.tfstate",
        "region": "us-east-1",
        "dynamodb_table": "terraform-locks",
        "encrypt": true
      }
    }
  }
}

GCS Backend (Google Cloud)

terraform {
  backend "gcs" {
    bucket = "my-terraform-state"
    prefix = "production"
  }
}

Azure Backend

terraform {
  backend "azurerm" {
    resource_group_name  = "terraform-state-rg"
    storage_account_name = "tfstateaccount"
    container_name       = "tfstate"
    key                  = "production.terraform.tfstate"
  }
}

Backend Nesting

The backend block is nested inside terraform, and the backend type (s3, gcs, azurerm) is a label that becomes an additional JSON nesting level: terraform.backend.s3.{attributes}.

State Locking

DynamoDB (AWS), native locking (GCS), and blob leases (Azure) provide state locking. These are configured as backend attributes and convert to simple JSON key-value pairs.

Use Case

Configuring remote state storage for team-based Terraform workflows, migrating backends between providers, or generating backend configurations for multi-environment Terraform setups.

Try It — HCL ↔ JSON Converter

Open full tool