pipr.tools
Pipes
Clean Email Strip formatting from pasted email for clean plain text Clean AI Output Clean plain text from ChatGPT or AI output Decode & Format JWT Decode a JWT and pretty-print header and payload Word Frequency Count word frequency in text

json-to-yaml Convert JSON to YAML

⟐ Data
Input0 chars
Output0 chars

Flags

--indent number default: 2

Examples

Convert a JSON object to YAML

Usage
"{"name":"Alice","age":30,"roles":["admin","editor"]}" | json-to-yaml

Convert a Docker config from JSON to YAML for Compose

Usage
"{"image":"nginx:latest","ports":[{"containerPort":80}],"env"..." | json-to-yaml

Convert application settings from JSON to human-friendly YAML

Usage
"{"title":"My App","version":"1.0","settings":{"debug":false,..." | json-to-yaml
View source
async (input, opts = {})=>{
                try {
                    const yaml = await import('js-yaml').then(async (m)=>{
                        await m.__tla;
                        return m;
                    });
                    return yaml.dump(JSON.parse(input), {
                        indent: parseInt(opts.indent) || 2
                    });
                } catch (e) {
                    return `Error: ${e.message}`;
                }
            }