Format-Specific Exploration Recipes
Per-format commands for exploring structured data with dasel v3. Each section covers the format's unique characteristics and provides concrete commands.
Table of Contents
- JSON Exploration
- YAML Exploration
- TOML Exploration
- XML Exploration
- CSV Exploration
- HCL Exploration
- INI Exploration
JSON Exploration
JSON is dasel's native format. All operations work without caveats.
Discover Structure
# Top-level keys
dasel -f data.json 'keys($this)'
# Nested object keys
dasel -f data.json 'keys(config.database)'
Inspect Arrays of Objects
# Preview first element to understand object shape
dasel -f data.json 'users[0]'
# Keys of first element (reveals schema of array items)
dasel -f data.json 'keys(users[0])'
# Count elements
dasel -f data.json 'len(users)'
# Sample first 3 elements
dasel -f data.json 'users[0:3]'
Search Nested Objects
# Find all objects containing "email" at any depth
dasel -f data.json 'search(has("email"))'
# Find objects where "status" equals "active"
dasel -f data.json 'search(status == "active")'
# Combined predicate
dasel -f data.json 'search(has("id") && has("name"))'
Extract Specific Fields from Arrays
# Get all names from users array
dasel -f data.json 'users.map(name)'
# Get all unique roles
dasel -f data.json 'users.map(role)' | dasel -i json '$this...' | sort -u
Mixed-Type Detection
# Check type of ambiguous field
dasel -f data.json 'typeOf(config.port)'
# Returns: "int", "string", "float", etc.
# Check if field is array or object
dasel -f data.json 'typeOf(metadata)'
YAML Exploration
YAML supports anchors, multi-document files, and deep nesting common in Kubernetes and CI configs.
Discover Structure
# Top-level keys
dasel -f config.yaml 'keys($this)'
# Deeply nested config (common in Kubernetes)
dasel -f deployment.yaml 'keys(spec.template.spec)'
Deep Nesting Navigation
# Step through Kubernetes manifest
dasel -f deployment.yaml 'keys($this)'
# -> ["apiVersion", "kind", "metadata", "spec"]
dasel -f deployment.yaml 'keys(spec)'
# -> ["replicas", "selector", "template"]
dasel -f deployment.yaml 'spec.template.spec.containers[0].image'
Inspect Nested Arrays
# List container names in a pod spec
dasel -f deployment.yaml 'spec.template.spec.containers.map(name)'
# Count containers
dasel -f deployment.yaml 'len(spec.template.spec.containers)'
# Get all environment variable names from first container
dasel -f deployment.yaml 'spec.template.spec.containers[0].env.map(name)'
Recursive Key Search
# Find all keys named "image" at any depth
dasel -f deployment.yaml '..image'
# Find all objects with a "name" field
dasel -f deployment.yaml 'search(has("name"))'
TOML Exploration
TOML uses tables (sections) and arrays of tables. Common in Rust (Cargo.toml), Python (pyproject.toml), and Go configs.
Enumerate Tables
# Top-level tables and keys
dasel -f pyproject.toml 'keys($this)'
# Nested tables
dasel -f Cargo.toml 'keys(dependencies)'
dasel -f pyproject.toml 'keys(tool.ruff)'
Inspect Arrays of Tables
# pyproject.toml optional-dependencies or similar array sections
dasel -f Cargo.toml 'keys(bin[0])'
dasel -f Cargo.toml 'len(bin)'
Value Extraction
# Package metadata
dasel -f pyproject.toml 'project.name'
dasel -f pyproject.toml 'project.version'
# Dependency list
dasel -f pyproject.toml 'keys(project.dependencies)'
Type Checking
# Verify field types (TOML distinguishes int, float, string, bool, datetime)
dasel -f config.toml 'typeOf(server.port)'
dasel -f config.toml 'typeOf(server.debug)'
XML Exploration
XML has elements, attributes, and text content. Dasel represents these as nested objects.
Element Listing
# Top-level element (XML has single root)
dasel -f data.xml 'keys($this)'
# Child elements
dasel -f pom.xml 'keys(project)'
dasel -f pom.xml 'keys(project.dependencies)'
Inspect Repeated Elements
# Count dependency entries in Maven POM
dasel -f pom.xml 'len(project.dependencies.dependency)'
# First dependency
dasel -f pom.xml 'project.dependencies.dependency[0]'
Attribute Access
XML attributes are accessible as properties on the element. The exact representation depends on dasel's XML mapping. Inspect the element first:
# View full element to see attribute representation
dasel -f data.xml 'root.element[0]'
Recursive Search
# Find all elements with a specific child
dasel -f data.xml 'search(has("version"))'
CSV Exploration
CSV files are represented as arrays of objects (header row becomes keys).
Header Extraction
# Get column names from first row
dasel -f data.csv 'keys($this[0])'
Row Count
dasel -f data.csv 'len($this)'
Sample Rows
# First row (as object with column keys)
dasel -f data.csv '$this[0]'
# First 3 rows
dasel -f data.csv '$this[0:3]'
Column Sampling
# Extract single column values
dasel -f data.csv '$this.map(name)'
# Unique values in a column
dasel -f data.csv '$this.map(category)' | dasel -i json '$this...' | sort -u
Type Inspection
CSV values are typically strings. Check with:
dasel -f data.csv 'typeOf($this[0].age)'
HCL Exploration
HCL (HashiCorp Configuration Language) uses blocks with labels. Common in Terraform files.
Block Discovery
# Top-level block types
dasel -f main.tf 'keys($this)'
# -> ["resource", "variable", "output", "provider"]
Inspect Block Labels
# Resource types
dasel -f main.tf 'keys(resource)'
# Specific resource
dasel -f main.tf 'resource.aws_instance'
dasel -f main.tf 'keys(resource.aws_instance)'
Nested Block Inspection
# Terraform resource attributes
dasel -f main.tf 'resource.aws_instance.web'
dasel -f main.tf 'keys(resource.aws_instance.web)'
Variable Discovery
# List all variable names
dasel -f variables.tf 'keys(variable)'
# Get variable default value
dasel -f variables.tf 'variable.region.default'
INI Exploration
INI files have sections and key-value pairs. Common in systemd, PHP, Git config.
Section Listing
# List all sections
dasel -f config.ini 'keys($this)'
Key Listing Within Section
# Keys in a specific section
dasel -f config.ini 'keys(database)'
dasel -f config.ini 'keys(server)'
Value Extraction
dasel -f config.ini 'database.host'
dasel -f config.ini 'server.port'
Full Section Dump
# View all keys and values in a section
dasel -f config.ini 'database'
Cross-Format Tips
- Type ambiguity: CSV and INI store everything as strings. Use
typeOf()to confirm before numeric operations. - XML root: XML always has exactly one root element.
keys($this)returns a single-element array. - TOML datetimes: TOML natively supports datetime types.
typeOf()reports these distinctly. - HCL labels: HCL block labels become nested object keys.
resource.aws_instance.webnavigates type -> label -> label. - Large files: Use
search()instead of recursive descent (..) when you need predicate-based filtering, not exhaustive traversal.
References
- Dasel Query Syntax (fetched 2026-02-19)
- Dasel Functions Index (fetched 2026-02-19)
- Dasel Arrays and Slices (fetched 2026-02-19)