🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis
Socket
Book a DemoInstallSign in
Socket

ymlify

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ymlify

Convert JSON, XML, CSV, TOML, and ENV files to YAML format

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

🔄 ymlify

Convert JSON, XML, CSV, TOML, and ENV files to YAML format with ease.

🚀 Installation

Global Installation

npm install -g ymlify

Local Installation

npm install ymlify

📖 Usage

CLI Usage

After global installation:

ymlify openapi.json
ymlify config.xml config.yml
ymlify data.csv
ymlify settings.toml
ymlify .env environment.yml

With npx (no installation required):

npx ymlify openapi.json

Programmatic Usage

import { ymlify, ymlifyString } from "ymlify";

// Convert file
ymlify("config.json", "config.yml");

// Convert string
const yamlString = ymlifyString('{"name": "value"}', "json");
console.log(yamlString);

// With options
ymlify("data.json", "data.yml", {
  indent: 4,
  lineWidth: 80,
  noRefs: true,
});

🎯 Supported Formats

  • JSON (.json) - JavaScript Object Notation
  • XML (.xml) - Extensible Markup Language
  • CSV (.csv) - Comma-Separated Values
  • TOML (.toml) - Tom's Obvious, Minimal Language
  • ENV (.env) - Environment Variables

🔧 API

ymlify(inputPath, outputPath?, options?)

Converts a file to YAML format.

  • inputPath (string): Path to the input file
  • outputPath (string, optional): Path to the output YAML file. Defaults to input filename with .yml extension
  • options (object, optional):
    • indent (number): Number of spaces for indentation (default: 2)
    • lineWidth (number): Maximum line width (default: -1, unlimited)
    • noRefs (boolean): Don't use anchors/references (default: true)
    • detectFormat (boolean): Auto-detect file format (default: true)

Returns: The output file path

ymlifyString(input, format, options?)

Converts a string to YAML format.

  • input (string): Content to convert
  • format (string): Format type ('json', 'xml', 'csv', 'toml', 'env')
  • options (object, optional): Same as above

Returns: YAML string

💡 Examples

Convert OpenAPI JSON to YAML

ymlify openapi.json openapi.yml

Convert XML configuration

ymlify config.xml

Convert CSV data

ymlify users.csv users.yml

Convert TOML settings

ymlify Cargo.toml

Convert ENV file

ymlify .env config.yml

Programmatic usage with TypeScript

import { ymlify, ymlifyString } from "ymlify";

// Convert a JSON file
const output = ymlify("./data.json");
console.log(`Created: ${output}`);

// Convert JSON string
const jsonStr = '{"server": {"port": 3000, "host": "localhost"}}';
const yaml = ymlifyString(jsonStr, "json");
console.log(yaml);

// Convert XML string
const xmlStr = "<config><port>3000</port></config>";
const yamlFromXml = ymlifyString(xmlStr, "xml");
console.log(yamlFromXml);

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

MIT

🐛 Issues

Found a bug? Please report it at the issues page.

Keywords

yaml

FAQs

Package last updated on 26 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts