{"id":15909351,"url":"https://github.com/anubhavmishra/json2hcl","last_synced_at":"2025-08-14T21:32:21.160Z","repository":{"id":57576415,"uuid":"228543123","full_name":"anubhavmishra/json2hcl","owner":"anubhavmishra","description":"Convert JSON to HCL","archived":false,"fork":false,"pushed_at":"2019-12-17T05:56:53.000Z","size":8,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-28T13:47:23.518Z","etag":null,"topics":["hcl","json","packer"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anubhavmishra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-17T05:53:00.000Z","updated_at":"2023-07-12T16:50:14.000Z","dependencies_parsed_at":"2022-08-29T00:51:52.969Z","dependency_job_id":null,"html_url":"https://github.com/anubhavmishra/json2hcl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anubhavmishra%2Fjson2hcl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anubhavmishra%2Fjson2hcl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anubhavmishra%2Fjson2hcl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anubhavmishra%2Fjson2hcl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anubhavmishra","download_url":"https://codeload.github.com/anubhavmishra/json2hcl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229870409,"owners_count":18137034,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hcl","json","packer"],"created_at":"2024-10-06T15:00:29.148Z","updated_at":"2024-12-15T20:20:17.563Z","avatar_url":"https://github.com/anubhavmishra.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# json2hcl\n\nConvert JSON to HCL\n\n## Usage\n\nDownload the latest version of `json2hcl` from [releases](https://github.com/anubhavmishra/json2hcl/releases).\n\n### Packer JSON config file to HCL example\n\nPacker JSON config file [examples/packer-config.json](./examples/packer-config.json)\n\n```json\n{\n  \"variables\": {\n    \"aws_access_key\": \"\",\n    \"aws_secret_key\": \"\"\n  },\n  \"builders\": [{\n    \"type\": \"amazon-ebs\",\n    \"access_key\": \"{{user `aws_access_key`}}\",\n    \"secret_key\": \"{{user `aws_secret_key`}}\",\n    \"region\": \"us-east-1\",\n    \"source_ami_filter\": {\n      \"filters\": {\n        \"virtualization-type\": \"hvm\",\n        \"name\": \"ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*\",\n        \"root-device-type\": \"ebs\"\n      },\n      \"owners\": [\"099720109477\"],\n      \"most_recent\": true\n    },\n    \"instance_type\": \"t2.micro\",\n    \"ssh_username\": \"ubuntu\",\n    \"ami_name\": \"packer-example {{timestamp}}\"\n  }]\n}\n```\n\nConvert Packer JSON config file to HCL\n\n```bash\njson2hcl \u003c examples/packer-config.json\n\"variables\" = {\n  \"aws_access_key\" = \"\"\n\n  \"aws_secret_key\" = \"\"\n}\n\n\"builders\" = {\n  \"type\" = \"amazon-ebs\"\n\n  \"access_key\" = \"{{user `aws_access_key`}}\"\n\n  \"secret_key\" = \"{{user `aws_secret_key`}}\"\n\n  \"region\" = \"us-east-1\"\n\n  \"source_ami_filter\" = {\n    \"filters\" = {\n      \"virtualization-type\" = \"hvm\"\n\n      \"name\" = \"ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*\"\n\n      \"root-device-type\" = \"ebs\"\n    }\n\n    \"owners\" = [\"099720109477\"]\n\n    \"most_recent\" = true\n  }\n\n  \"instance_type\" = \"t2.micro\"\n\n  \"ssh_username\" = \"ubuntu\"\n\n  \"ami_name\" = \"packer-example {{timestamp}}\"\n}\n```\n\nTo validate Packer HCL configuration run the following command\n\n```bash\npacker validate packer-config.hcl\nTemplate validated successfully.\n```\n\n## Acknowledgements\n\nThis project is inspired by [kvz/json2hcl](https://github.com/kvz/json2hcl). This project aims to be\nlightweight and only support JSON to HCL conversion. If you want to convert HCL to JSON, please use\n[kvz/json2hcl](https://github.com/kvz/json2hcl).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanubhavmishra%2Fjson2hcl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanubhavmishra%2Fjson2hcl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanubhavmishra%2Fjson2hcl/lists"}