{"id":44880674,"url":"https://github.com/corpix/formats","last_synced_at":"2026-02-17T16:04:47.293Z","repository":{"id":57501454,"uuid":"82194896","full_name":"corpix/formats","owner":"corpix","description":"Transform data between arbitrary formats in go","archived":false,"fork":false,"pushed_at":"2019-06-09T02:56:03.000Z","size":241,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-14T14:24:14.958Z","etag":null,"topics":["converter","json","toml","yaml"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/corpix.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":"2017-02-16T15:25:28.000Z","updated_at":"2019-06-09T02:57:45.000Z","dependencies_parsed_at":"2022-08-30T14:40:19.591Z","dependency_job_id":null,"html_url":"https://github.com/corpix/formats","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/corpix/formats","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corpix%2Fformats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corpix%2Fformats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corpix%2Fformats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corpix%2Fformats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/corpix","download_url":"https://codeload.github.com/corpix/formats/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corpix%2Fformats/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29549243,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T14:33:00.708Z","status":"ssl_error","status_checked_at":"2026-02-17T14:32:58.657Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["converter","json","toml","yaml"],"created_at":"2026-02-17T16:04:45.104Z","updated_at":"2026-02-17T16:04:47.288Z","avatar_url":"https://github.com/corpix.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"formats\n----------\n\n[![Build Status](https://travis-ci.org/corpix/formats.svg?branch=master)](https://travis-ci.org/corpix/formats)\n\nThis package provides:\n\n- command-line tool which converts stdin from format A to format B\n- library with consistent API to transform data from format A to format B\n\nSupported formats:\n\n- `JSON`\n- `YAML`\n- `TOML`\n\n## Command-line tool example\n\n``` console\n$ go get -u github.com/corpix/formats/...\n...\n\n$ echo '{\"hello\": [\"world\", {\"of\": \"foo\", \"bar\": true}]}' | formats --from json --to yaml\nhello:\n- world\n- bar: true\n  of: foo\n\n$ echo '{\"hello\": [\"world\", {\"of\": \"foo\", \"bar\": true}]}' | formats --from json --to yaml | formats --from yaml --to json\n{\"hello\":[\"world\",{\"bar\":\"true\",\"of\":\"foo\"}]}\n\n$ echo -n 'hello' | formats --to hex\n68656c6c6f\n\n$ echo -n '68656c6c6f' | formats --from hex\nhello\n\n$ echo -n '68656c6c6f' | formats --from hex --to json\n\"hello\"\n```\n\n## Library usage example\n\nThis will convert JSON to YAML:\n\n``` go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/corpix/formats\"\n)\n\nvar (\n\tjson = `\n        {\n            \"name\": \"Danny\",\n            \"roles\": [\"warrior\", \"worker\"]\n        }\n    `\n)\n\nfunc main() {\n\tv := new(interface{})\n\n\tj := formats.NewJSON()\n\terr := j.Unmarshal(\n\t\t[]byte(json),\n\t\tv,\n\t)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\ty := formats.NewYAML()\n\tyaml, err := y.Marshal(v)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(string(yaml))\n}\n```\n\n``` console\n$ go run ./example/json-to-yaml/json-to-yaml.go\nname: Danny\nroles:\n- name: warrior\n- name: worker\n\n$ go run ./example/json-to-toml/json-to-toml.go\nname = \"Danny\"\n\n[[roles]]\nname = \"warrior\"\n\n[[roles]]\nname = \"worker\"\n\n```\n\n## Limitations\n\nThere is a compatibility layer for:\n\n- `JSON`, which helps to [mitigate](https://github.com/go-yaml/yaml/issues/139) non string keys in maps before they will be marshaled into `JSON`\n\n### YAML\n\n[go-yaml](https://github.com/go-yaml/yaml) handles struct keys without tags in [non-standard way](https://github.com/go-yaml/yaml/issues/148), they are lowercased.\n\nThere is no good workaround for this at the time of writing. Make sure you have tags for your struct field.\n\n\u003e Actualy I'd like to switch to more configurable yaml marshaler in the future, but at this time there is nothing better :(\n\n### TOML\n\n[toml](https://github.com/naoina/toml) can not marshal `interface{}` values at this time(panics, requires struct or map).\n\n\u003e Which is strange, probably some reflection misuse.\n\n## License\n\nunlicense\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorpix%2Fformats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcorpix%2Fformats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorpix%2Fformats/lists"}