Kubernetes

Kubernetes label selectorwith a reason for every match

Check label syntax, then see which conditions select each supplied resource.

Kubernetes label selector

Labels or resources JSON

Matching results

Inputs stay in this browser. No cluster connection, upload or network lookup.

Input settings and supported syntax

= · == · != · in · notin · key · !key. Commas join conditions with AND; an empty selector matches all inputs.

Limits: 500,000 JSON characters, 8,192 selector characters, 500 resources, 64 conditions, 256 labels per resource.

Semantics: Kubernetes 1.35 / apimachinery v0.35.0; equality, set and existence selectors only.

Input changed. Test again before exporting.

A Kubernetes label selector can look right and still choose an unexpected Pod. The usual surprise is a missing key: env!=prod also accepts an object with no env label. Inspect the actual condition results before changing a Service or a kubectl query.

Use a label map for a small experiment or choose resource mode for JSON returned by kubectl. Both modes keep their own input, so switching views does not turn a label named metadata into a resource wrapper.

Why inspect a Kubernetes label selector?

Find the condition that excludes a resource

This Kubernetes label selector tester evaluates every clause, even when an earlier clause fails. A web Pod in development can fail the environment condition while still passing !paused. You get a diagnosis for that specific object, rather than guessing from an empty list.

Three resource cards pass through a condition chain; only the card satisfying every condition reaches the matching group.

Separate an empty value from a missing key

A label with the value "" still exists. An absent key has no value at all. The explanation shows these states separately, so a negative condition cannot quietly be mistaken for an existence check.

Three label cards show a filled slot, an empty slot and no slot, each with its own decision path.

Three checks before using a selector

01

Choose where labels live

Label-map mode reads the entire object. Resource mode reads only metadata.labels from a single object, an array, or a Kubernetes List. It does not descend into a Deployment’s Pod template.

02

Challenge the default example

Change production to development, then remove the environment key. Compare in with notin to see how absence changes the decision. Turn off auto test to run with Ctrl/Cmd + Enter instead.

03

Read the complete report

Expand a resource to inspect its labels and all conditions. Results appear 50 at a time; copying or downloading still includes every resource. Any input edit disables export until a fresh test finishes.

Validation and matching in one report

Keys and values have different rules

The Kubernetes label validator checks an optional lowercase DNS prefix, a 1–63 character name and a value of up to 63 characters. Names may include uppercase letters; values may be empty. Reserved prefixes remain syntactically valid.

Equality and sets share one AND chain

Use = or == for equality, != for exclusion, and in or notin for a set-based selector. Each comma between clauses is AND. Several alternatives for the same key belong inside one in expression; a second clause narrows the result.

Batch results keep their identity

Resource mode records the original index, JSON path, kind, namespace and name when supplied. Missing or null metadata.labels becomes an empty map. Duplicate names remain separate entries, so no item disappears through deduplication.

Values remain strings

The label selector tester refuses numeric, boolean or null label values. It also rejects duplicate JSON keys instead of letting a later value overwrite an earlier one. A string such as "01" stays distinct from "1" throughout matching.

Scope, input limits and API differences

A defined string-selector subset
Semantics follow Kubernetes 1.35 / apimachinery v0.35.0 for equality, sets and existence. Numeric < or >, cross-key OR, wildcards, regular expressions, field selectors and node-affinity rules are outside this tool.
JSON only, with explicit mode selection
Paste strict JSON without comments or trailing commas. YAML, file uploads, URL fetching and structured matchLabels or matchExpressions are not accepted. In resource mode, a List or *List kind requires an items array; ordinary resources use their own metadata.labels.
Bounded batches fail as a whole
Limits are 500,000 JSON characters, 8,192 selector characters, 500 resources, 64 clauses and 256 labels per resource. Character counts use UTF-16 code units. JSON is also bounded to depth 100, 50,000 nodes and 1,000 characters per number. Any invalid label or over-limit input blocks the whole report.
An empty query has a specific meaning
An empty kubectl label selector string matches all valid supplied objects here. It does not mean every API accepts an empty selector. Service selectors, null structured selectors and controller validation have their own rules. An empty JSON editor is not a label map; enter {} explicitly.
A report is a snapshot, not a manifest
Exports contain selected identity fields, labels and condition results. Unrelated resource fields are omitted. No labels are fixed, no resource is rewritten, and the report cannot establish readiness, Service endpoints, routing or controller ownership.

Kubernetes label selector questions

How do I query Pods by several labels?

Join requirements with commas, for example app=web,environment=production. Both must pass. Keep any DNS prefix in the key, such as app.kubernetes.io/name=web. Namespaced and unprefixed keys are different labels.

Can I use OR between label conditions?

There is no cross-key OR in this syntax. For alternatives on one key, environment in (production,staging) accepts either value. Combining two equality clauses for that key uses AND and may be impossible to satisfy.

Can a label have a key without a value?

Yes, encode it as {"maintenance":""}. maintenance checks that the key exists; maintenance= checks for the empty string; !maintenance requires the key to be absent. In string syntax, maintenance in () also selects an existing empty value.

How can I count resources that lack a label?

Use !key and read the matched count. This finds objects without that particular key, not necessarily objects with no labels at all. For cluster-wide counts, obtain a complete resource list separately; this page counts only the supplied snapshot.

Why does env!=prod match an object with no env label?

Negative equality and notin include missing keys. Add an existence condition, env,env!=prod, when you require a present value other than prod. The per-condition explanation distinguishes that case from a present nonmatching value.

Still have a selector question?

Check the labels you actually have

Run the Kubernetes label selector against your current JSON and inspect the failed clauses before editing a workload configuration.