README
ΒΆ
SerdeVal
A privacy-focused, blazingly fast data format validator supporting 14+ formats including JSON, YAML, XML, TOML, CSV, GraphQL, Markdown, and more.
Privacy-focused: All validation happens locally on your machine.
π Live Demo
freedatavalidator.xyz - Try it online (client-side validation)
π Features
- π Privacy-First: No logging, tracking, or data retention
- β‘ Blazingly Fast: Zero-dependency Go implementation
- π― Auto-Detection: Automatically detects data formats
- π± Multiple Interfaces: CLI, Go library, and web interface
- π Cross-Platform: Windows, macOS, and Linux support
- π§ Smart Formatting: Beautifies and validates in one step
- π Developer-Friendly: JSON output for CI/CD pipelines
Supported Formats
| Format | Extensions | Auto-Detection | Validation | Use Case |
|---|---|---|---|---|
| JSON | .json |
β | β | APIs, Config files |
| YAML | .yaml, .yml |
β | β | Kubernetes, CI/CD |
| XML | .xml |
β | β | Enterprise, SOAP |
| TOML | .toml |
β | β | Config files |
| CSV | .csv |
β | β | Data exchange |
| GraphQL | .graphql, .gql |
β | β | API schemas |
| INI | .ini, .cfg, .conf |
β | β | Config files |
| HCL | .hcl, .tf, .tfvars |
β | β | Terraform |
| Protobuf | .proto, .textproto |
β | β | Protocol Buffers |
| Markdown | .md, .markdown |
β | β | Documentation |
| JSON Lines | .jsonl, .ndjson |
β | β | Streaming data |
| Jupyter | .ipynb |
β | β | Data science |
| Requirements.txt | .txt |
β | β | Python deps |
| Dockerfile | Dockerfile* |
β | β | Containers |
π¦ Installation
Using Go
# As a CLI tool
go install github.com/akhilesharora/serdeval/cmd/serdeval@latest
# As a library
go get github.com/akhilesharora/serdeval/pkg/validator
Pre-built Binaries
Download the latest binary for your platform from the releases page.
From Source
Linux/macOS
git clone https://github.com/akhilesharora/serdeval
cd serdeval
make build
Windows
git clone https://github.com/akhilesharora/serdeval
cd serdeval
go build -o serdeval.exe ./cmd/serdeval
Development Setup
For contributors, set up pre-commit hooks to ensure code quality:
# Install pre-commit hooks
make pre-commit
# Or manually
./scripts/setup-hooks.sh
This will install hooks that:
- Format code automatically
- Run tests before push
- Check for linting issues
- Prevent commits with formatting errors
Deployment
For server deployment, copy deploy.example.sh to deploy.sh and customize it with your specific configuration:
cp deploy.example.sh deploy.sh
# Edit deploy.sh with your server details
π₯οΈ Usage
Command Line Interface
Basic Usage
# Validate a single file (auto-detects format)
serdeval validate config.json
# Validate multiple files
serdeval validate config.json data.yaml settings.toml
# Validate from stdin
echo '{"name": "John", "age": 30}' | serdeval validate
# Specify format explicitly
serdeval validate --format json config.txt
# Output as JSON for CI/CD pipelines
serdeval validate --json config.json
# Start web interface
serdeval web --port 8080
Validate Each Format
# JSON files
serdeval validate package.json
serdeval validate data.json
# YAML files
serdeval validate docker-compose.yaml
serdeval validate config.yml
# XML files
serdeval validate pom.xml
serdeval validate web.xml
# TOML files
serdeval validate Cargo.toml
serdeval validate pyproject.toml
# CSV files
serdeval validate data.csv
serdeval validate report.csv
# GraphQL files
serdeval validate schema.graphql
serdeval validate query.gql
# INI/Config files
serdeval validate config.ini
serdeval validate settings.cfg
serdeval validate app.conf
# HCL/Terraform files
serdeval validate main.tf
serdeval validate variables.tfvars
serdeval validate config.hcl
# Protobuf text format
serdeval validate message.textproto
serdeval validate data.pbtxt
# Markdown files
serdeval validate README.md
serdeval validate docs.markdown
# JSON Lines files
serdeval validate logs.jsonl
serdeval validate events.ndjson
# Jupyter notebooks
serdeval validate analysis.ipynb
# Python requirements
serdeval validate requirements.txt
serdeval validate requirements-dev.txt
# Dockerfiles
serdeval validate Dockerfile
serdeval validate Dockerfile.prod
Go Library
Basic Usage
package main
import (
"fmt"
"log"
"github.com/akhilesharora/serdeval/pkg/validator"
)
func main() {
// Auto-detect format
data := []byte(`{"name": "John", "age": 30}`)
result := validator.ValidateAuto(data)
if result.Valid {
fmt.Printf("Valid %s data\n", result.Format)
} else {
log.Fatalf("Invalid data: %s", result.Error)
}
}
Examples for Each Format
// JSON Validation
jsonValidator, _ := validator.NewValidator(validator.FormatJSON)
result := jsonValidator.ValidateString(`{"name": "test", "value": 123}`)
fmt.Printf("JSON valid: %v\n", result.Valid)
// YAML Validation
yamlValidator, _ := validator.NewValidator(validator.FormatYAML)
result = yamlValidator.ValidateString(`
name: test
value: 123
items:
- one
- two
`)
fmt.Printf("YAML valid: %v\n", result.Valid)
// XML Validation
xmlValidator, _ := validator.NewValidator(validator.FormatXML)
result = xmlValidator.ValidateString(`<?xml version="1.0"?>
<root>
<name>test</name>
<value>123</value>
</root>`)
fmt.Printf("XML valid: %v\n", result.Valid)
// TOML Validation
tomlValidator, _ := validator.NewValidator(validator.FormatTOML)
result = tomlValidator.ValidateString(`
[server]
host = "localhost"
port = 8080
`)
fmt.Printf("TOML valid: %v\n", result.Valid)
// CSV Validation
csvValidator, _ := validator.NewValidator(validator.FormatCSV)
result = csvValidator.ValidateString(`name,age,city
John,30,NYC
Jane,25,LA`)
fmt.Printf("CSV valid: %v\n", result.Valid)
// GraphQL Validation
graphqlValidator, _ := validator.NewValidator(validator.FormatGraphQL)
result = graphqlValidator.ValidateString(`
query GetUser {
user(id: "123") {
name
email
}
}`)
fmt.Printf("GraphQL valid: %v\n", result.Valid)
// INI Validation
iniValidator, _ := validator.NewValidator(validator.FormatINI)
result = iniValidator.ValidateString(`
[database]
host = localhost
port = 5432
`)
fmt.Printf("INI valid: %v\n", result.Valid)
// HCL Validation
hclValidator, _ := validator.NewValidator(validator.FormatHCL)
result = hclValidator.ValidateString(`
resource "aws_instance" "example" {
ami = "ami-12345"
instance_type = "t2.micro"
}`)
fmt.Printf("HCL valid: %v\n", result.Valid)
// Protobuf Text Validation
protoValidator, _ := validator.NewValidator(validator.FormatProtobuf)
result = protoValidator.ValidateString(`
type_url: "type.googleapis.com/example"
value: "\n\x05hello"
`)
fmt.Printf("Protobuf valid: %v\n", result.Valid)
// Markdown Validation
mdValidator, _ := validator.NewValidator(validator.FormatMarkdown)
result = mdValidator.ValidateString(`# Title
This is **bold** text.
- Item 1
- Item 2
`)
fmt.Printf("Markdown valid: %v\n", result.Valid)
// JSON Lines Validation
jsonlValidator, _ := validator.NewValidator(validator.FormatJSONL)
result = jsonlValidator.ValidateString(`{"event": "login", "user": "john"}
{"event": "logout", "user": "john"}
{"event": "login", "user": "jane"}`)
fmt.Printf("JSONL valid: %v\n", result.Valid)
// Jupyter Notebook Validation
jupyterValidator, _ := validator.NewValidator(validator.FormatJupyter)
result = jupyterValidator.ValidateString(`{
"cells": [],
"metadata": {"kernelspec": {"name": "python3"}},
"nbformat": 4,
"nbformat_minor": 2
}`)
fmt.Printf("Jupyter valid: %v\n", result.Valid)
// Requirements.txt Validation
reqValidator, _ := validator.NewValidator(validator.FormatRequirements)
result = reqValidator.ValidateString(`numpy==1.21.0
pandas>=1.3.0
scikit-learn~=1.0.0`)
fmt.Printf("Requirements valid: %v\n", result.Valid)
// Dockerfile Validation
dockerValidator, _ := validator.NewValidator(validator.FormatDockerfile)
result = dockerValidator.ValidateString(`FROM python:3.9
WORKDIR /app
COPY . .
RUN pip install -r requirements.txt
CMD ["python", "app.py"]`)
fmt.Printf("Dockerfile valid: %v\n", result.Valid)
Web Interface
Start the built-in web server:
serdeval web --port 8080
Then visit http://localhost:8080 for a user-friendly interface with:
- Real-time validation as you type
- Auto-format with beautification
- Copy-to-clipboard functionality
- Format auto-detection
- 100% client-side processing (your data never leaves your browser)
π οΈ Development
Prerequisites
- Go 1.22 or higher
- Make (optional, for convenience commands)
Building
# Build for current platform
make build
# Build for all platforms
make build-all
# Run tests
make test
# Run linters
make lint
# Format code
make fmt
# Run benchmarks
make bench
Testing
# Run all tests
go test ./...
# Run tests with coverage
go test -coverprofile=coverage.out ./...
# Run benchmarks
go test -bench=. ./...
π€ Contributing
We welcome contributions! Please see CONTRIBUTING.md for details.
Quick Start for Contributors
- Fork the repository
- Set up development environment:
make pre-commit - Make your changes
- Run tests:
make test - Submit a pull request
Please read our Code of Conduct.
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
- Built with β€οΈ for the developer community
- Inspired by the need for privacy-focused validation tools
- Thanks to all contributors who help improve this project
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
serdeval
command
Command serdeval provides a CLI for validating JSON, YAML, XML, and TOML files.
|
Command serdeval provides a CLI for validating JSON, YAML, XML, and TOML files. |
|
pkg
|
|
|
validator
Package validator provides a privacy-focused data format validation library for Go.
|
Package validator provides a privacy-focused data format validation library for Go. |