Skip to content

Convert from raw JSON to a pretty jsonencode() call for OpenTofu/Hashicorp Terraform

License

Notifications You must be signed in to change notification settings

karolba/json-to-pretty-hcl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json-to-pretty-hcl

Convert JSON to pretty jsonencode() HCL calls for Terraform or OpenTofu

Usage - the web

Try it online: json-to-pretty-jsonencode.baraniecki.eu

Usage - CLI

Or use the CLI via npx:

# Convert JSON from the clipboard to HCL (Linux)
$ xsel -b | npx json-to-pretty-hcl -
jsonencode(...)
# Convert JSON from the clipboard to HCL (macOS)
$ pbpaste | npx json-to-pretty-hcl -
jsonencode(...)
# Convert a JSON file to HCL
$ cat package.json
{
  "name": "json-to-pretty-hcl",
  "version": "0.0.2",
  "description": "Convert JSON to pretty OpenTofu/Terraform jsonencode() calls",
  "main": "index.mjs",
  "bin": {
    "json-to-pretty-hcl": "./index.mjs"
  },
  "engines": {
    "node" : ">=13.0.0"
  },
  "scripts": {
    "cloudflare-pages-build": "mkdir -p website-dist && cp -rv index.html modules vendor website-dist/",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "exports": {
    "./*": "./modules/*.mjs"
  },
  "repository": "github:karolba/json-to-pretty-hcl",
  "keywords": [
    "json",
    "jsonencode",
    "terraform",
    "tofu",
    "pretty"
  ],
  "author": {
    "name": "Karol Baraniecki",
    "url": "https://baraniecki.eu"
  },
  "license": "AGPL-3.0-or-later",
  "bugs": {
    "url": "https://github.com/karolba/json-to-pretty-hcl/issues"
  },
  "homepage": "https://json-to-pretty-jsonencode.baraniecki.eu/",
  "publishConfig": {
    "access": "public",
    "registry": "https://registry.npmjs.org/"
  }
}
$ npx json-to-pretty-hcl package.json
jsonencode({
    name        = "json-to-pretty-hcl"
    version     = "0.0.2"
    description = "Convert JSON to pretty OpenTofu/Terraform jsonencode() calls"
    main        = "index.mjs"
    bin = {
        "json-to-pretty-hcl" = "./index.mjs"
    }
    engines = {
        node = ">=13.0.0"
    }
    scripts = {
        "cloudflare-pages-build" = "mkdir -p website-dist && cp -rv index.html modules vendor website-dist/"
        test                     = "echo \"Error: no test specified\" && exit 1"
    }
    exports = {
        "./*" = "./modules/*.mjs"
    }
    repository = "github:karolba/json-to-pretty-hcl"
    keywords = [
        "json",
        "jsonencode",
        "terraform",
        "tofu",
        "pretty"
    ]
    author = {
        name = "Karol Baraniecki"
        url  = "https://baraniecki.eu"
    }
    license = "AGPL-3.0-or-later"
    bugs = {
        url = "https://github.com/karolba/json-to-pretty-hcl/issues"
    }
    homepage = "https://json-to-pretty-jsonencode.baraniecki.eu/"
    publishConfig = {
        access   = "public"
        registry = "https://registry.npmjs.org/"
    }
})

About

Convert from raw JSON to a pretty jsonencode() call for OpenTofu/Hashicorp Terraform

Resources

License

Stars

Watchers

Forks

Packages

No packages published