Convert Terraform Output Values to JSON

Convert Terraform output blocks that expose module values, including descriptions, sensitive flags, and value expressions.

Variables & Outputs

Detailed Explanation

Terraform Outputs in HCL and JSON

Output values are the return values of a Terraform module. They expose computed values to the parent module or to the CLI after terraform apply.

HCL Output Definitions

output "vpc_id" {
  description = "ID of the created VPC"
  value       = "aws_vpc.main.id"
}

output "public_subnet_ids" {
  description = "IDs of public subnets"
  value       = ["aws_subnet.public.*.id"]
}

output "database_endpoint" {
  description = "RDS database connection endpoint"
  value       = "aws_db_instance.main.endpoint"
  sensitive   = true
}

output "load_balancer_dns" {
  description = "DNS name of the application load balancer"
  value       = "aws_lb.main.dns_name"
}

JSON Structure

{
  "output": {
    "vpc_id": {
      "description": "ID of the created VPC",
      "value": "aws_vpc.main.id"
    },
    "database_endpoint": {
      "description": "RDS database connection endpoint",
      "value": "aws_db_instance.main.endpoint",
      "sensitive": true
    }
  }
}

Sensitive Outputs

The sensitive = true flag prevents Terraform from displaying the value in CLI output. In JSON, this is a simple boolean attribute.

Value Expressions

Output value attributes typically contain references to other resources. In JSON, these are string representations of the HCL expression. Terraform evaluates them during plan/apply.

Dependencies

Outputs create implicit dependencies. Terraform ensures the referenced resources are created before computing the output value. This dependency graph is maintained regardless of HCL or JSON format.

Use Case

Exposing infrastructure details from Terraform modules for consumption by other modules or external systems. Converting outputs to JSON is useful when building module registries, generating documentation, or integrating with configuration management tools.

Try It — HCL ↔ JSON Converter

Open full tool