Skip to main content

API Documentation

Programmatic access to DataValidate Pro conversion and validation tools. All conversions run client-side in your browser.

All processing happens client-side. No server API calls required.

Overview

DataValidate Pro tools are implemented as client-side JavaScript functions. While we don't provide a traditional REST API, you can use our conversion libraries directly in your own JavaScript/TypeScript projects, or replicate the functionality using the same open-source libraries we use.

This documentation provides code examples for common conversions using popular libraries and command-line tools.

YAML ↔ JSON Conversion

JavaScript / Node.js

Using js-yaml library:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Install: npm install js-yaml
const yaml = require('js-yaml');

const yamlString = `
name: DataValidate Pro
version: 1.0.0
features:
  - YAML converter
  - JSON validator
  - JWT decoder
`;

try {
  const jsonData = yaml.load(yamlString);
  console.log(JSON.stringify(jsonData, null, 2));
} catch (error) {
  console.error('YAML parsing error:', error.message);
}

Python

Using PyYAML library:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Install: pip install PyYAML
import yaml
import json

yaml_string = """
name: DataValidate Pro
version: 1.0.0
features:
  - YAML converter
  - JSON validator
  - JWT decoder
"""

try:
    data = yaml.safe_load(yaml_string)
    json_output = json.dumps(data, indent=2)
    print(json_output)
except yaml.YAMLError as e:
    print(f"YAML parsing error: {e}")

Command Line (yq)

Using yq command-line tool:

1
2
3
4
5
6
7
8
9
10
# Install yq: brew install yq (macOS) or snap install yq (Linux)

# Convert YAML to JSON
yq eval -o=json input.yaml > output.json

# Convert JSON to YAML
yq eval -P input.json > output.yaml

# Pretty print YAML as JSON
cat config.yaml | yq eval -o=json

CSV ↔ JSON Conversion

JavaScript / Node.js

Using papaparse library:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Install: npm install papaparse
const Papa = require('papaparse');

const csvString = `name,email,role
John Doe,john@example.com,Developer
Jane Smith,jane@example.com,Designer`;

const result = Papa.parse(csvString, {
  header: true,
  skipEmptyLines: true,
});

console.log(JSON.stringify(result.data, null, 2));

// Convert JSON to CSV
const jsonData = [
  { name: 'John Doe', email: 'john@example.com', role: 'Developer' },
  { name: 'Jane Smith', email: 'jane@example.com', role: 'Designer' }
];

const csv = Papa.unparse(jsonData);
console.log(csv);

Python

Using Python's built-in csv module:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import csv
import json

# CSV to JSON
csv_string = """name,email,role
John Doe,john@example.com,Developer
Jane Smith,jane@example.com,Designer"""

reader = csv.DictReader(csv_string.splitlines())
data = list(reader)
print(json.dumps(data, indent=2))

# JSON to CSV
json_data = [
    {"name": "John Doe", "email": "john@example.com", "role": "Developer"},
    {"name": "Jane Smith", "email": "jane@example.com", "role": "Designer"}
]

with open('output.csv', 'w', newline='') as f:
    writer = csv.DictWriter(f, fieldnames=['name', 'email', 'role'])
    writer.writeheader()
    writer.writerows(json_data)

Command Line (csvkit)

Using csvkit toolkit:

1
2
3
4
5
6
7
8
9
10
# Install csvkit: pip install csvkit

# Convert CSV to JSON
csvjson input.csv > output.json

# Convert JSON to CSV
in2csv --format json input.json > output.csv

# Pretty print CSV as JSON
cat data.csv | csvjson | jq

XML ↔ JSON Conversion

JavaScript / Node.js

Using xml-js library:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Install: npm install xml-js
const convert = require('xml-js');

const xmlString = `<?xml version="1.0"?>
<user>
  <name>John Doe</name>
  <email>john@example.com</email>
  <role>Developer</role>
</user>`;

const result = convert.xml2json(xmlString, {
  compact: true,
  spaces: 2
});

console.log(result);

// Convert JSON to XML
const jsonString = JSON.stringify({ user: { name: 'John', email: 'john@example.com' }});
const xml = convert.json2xml(jsonString, { compact: true, spaces: 2 });
console.log(xml);

Python

Using xmltodict library:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Install: pip install xmltodict
import xmltodict
import json

xml_string = """

  John Doe
  john@example.com
  Developer
"""

data = xmltodict.parse(xml_string)
print(json.dumps(data, indent=2))

# Convert JSON to XML
json_data = {"user": {"name": "John", "email": "john@example.com"}}
xml_output = xmltodict.unparse(json_data, pretty=True)
print(xml_output)

JWT Decoding

JavaScript / Node.js

Using jsonwebtoken library:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Install: npm install jsonwebtoken
const jwt = require('jsonwebtoken');

const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';

// Decode without verification (for inspection only)
const decoded = jwt.decode(token, { complete: true });
console.log('Header:', decoded.header);
console.log('Payload:', decoded.payload);

// Verify and decode (with secret)
try {
  const verified = jwt.verify(token, 'your-secret-key');
  console.log('Verified payload:', verified);
} catch (error) {
  console.error('Verification failed:', error.message);
}

Python

Using PyJWT library:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Install: pip install PyJWT
import jwt
import json

token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"

# Decode without verification (for inspection only)
decoded = jwt.decode(token, options={"verify_signature": False})
print(json.dumps(decoded, indent=2))

# Verify and decode (with secret)
try:
    verified = jwt.decode(token, "your-secret-key", algorithms=["HS256"])
    print("Verified:", json.dumps(verified, indent=2))
except jwt.InvalidTokenError as e:
    print(f"Verification failed: {e}")

Command Line (base64)

Basic JWT decoding without verification:

1
2
3
4
5
6
7
8
9
10
11
12
# Decode JWT without verification (base64 decode)
# Split token into parts and decode payload
TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"

# Extract payload (second part)
PAYLOAD=$(echo $TOKEN | cut -d'.' -f2)

# Decode base64 (add padding if needed)
echo $PAYLOAD | base64 -d | jq

# Full one-liner
echo $TOKEN | cut -d'.' -f2 | base64 -d | jq

Base64 Encoding/Decoding

JavaScript / Node.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Node.js built-in Buffer

// Encode
const text = "Hello, DataValidate Pro!";
const encoded = Buffer.from(text).toString('base64');
console.log('Encoded:', encoded);

// Decode
const decoded = Buffer.from(encoded, 'base64').toString('utf-8');
console.log('Decoded:', decoded);

// URL-safe Base64
const urlSafe = encoded.replace(/+/g, '-').replace(///g, '_').replace(/=/g, '');
console.log('URL-safe:', urlSafe);

Python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import base64

# Encode
text = "Hello, DataValidate Pro!"
encoded = base64.b64encode(text.encode()).decode()
print(f"Encoded: {encoded}")

# Decode
decoded = base64.b64decode(encoded).decode()
print(f"Decoded: {decoded}")

# URL-safe Base64
url_safe = base64.urlsafe_b64encode(text.encode()).decode()
print(f"URL-safe: {url_safe}")

Command Line

1
2
3
4
5
6
7
8
9
10
11
# Encode
echo "Hello, DataValidate Pro!" | base64

# Decode
echo "SGVsbG8sIERhdGFWYWxpZGF0ZSBQcm8hCg==" | base64 -d

# Encode file
base64 input.txt > output.b64

# Decode file
base64 -d input.b64 > output.txt

Recommended Libraries

JavaScript / TypeScript

  • js-yaml - YAML parser and dumper
  • papaparse - Powerful CSV parser
  • xml-js - XML to JSON converter
  • jsonwebtoken - JWT implementation

Python

  • PyYAML - YAML parser and emitter
  • csv - Built-in CSV module
  • xmltodict - XML to dict converter
  • PyJWT - JWT implementation

Try Our Online Tools

Looking for a quick conversion without writing code? Try our browser-based tools:

Need more advanced text processing tools? Check out TextDiff for powerful text comparison and diff utilities.

For more developer tools, visit loadtime.dev.

DataValidate Pro

Developer data validation & conversion suite

Privacy First

All processing happens in your browser. Your data never leaves your device.

Read our Privacy Policy →

© 2025 DataValidate Pro

Free tools for developers

Disclaimer: The tools provided on DataValidate Pro are for informational and development purposes only. While we strive for accuracy, these tools should not be relied upon for critical business decisions, legal compliance, security assessments, or production deployments without proper validation. Always verify results independently and consult with qualified professionals for important decisions. We make no warranties about the accuracy, reliability, or completeness of any conversions or validations performed by these tools.