YAML and JSON Configuration Formats
What are YAML and JSON? When would you use each format in DevOps?
What are YAML and JSON? When would you use each format in DevOps?
YAML (YAML Ain't Markup Language) and JSON (JavaScript Object Notation) are data serialization formats. YAML is human-readable with indentation-based syntax, supports comments, and is preferred for configuration files (Kubernetes, Ansible, CI/CD). JSON is more compact, has strict syntax, and is preferred for APIs and machine-to-machine communication. Both represent the same data structures: objects/maps, arrays/lists, and scalar values.
DevOps engineers work with YAML and JSON daily. Kubernetes manifests, Helm charts, GitHub Actions, and Ansible playbooks all use YAML. APIs typically return JSON. Understanding both formats and being able to convert between them is essential. Common pitfalls include YAML indentation errors and JSON trailing commas.
YAML example
Equivalent JSON
- Using tabs instead of spaces in YAML (only spaces allowed)
- Inconsistent indentation in YAML files
- Trailing commas in JSON arrays/objects (not allowed)
- Forgetting to quote strings with special characters in YAML
- What common YAML mistakes cause parsing errors?
- How do you validate YAML or JSON files?
- What tools can convert between YAML and JSON?
More DevOps interview questions
Also worth your time on this topic
How to Use Multiple Build Arguments in Docker Build
Learn how to pass multiple build-time variables to Docker builds using --build-arg, set default values in Dockerfiles, and use build arguments for environment-specific configurations.
CI/CD Pipeline Stages
What are the typical stages of a CI/CD pipeline and why is each stage important?
junior
CI/CD Pipeline Setup Checklist
Step-by-step checklist for a production-ready CI/CD pipeline: source control, builds, tests, security scans, deploy gates, secrets, and rollback paths.
1-2 hours