Browse Clojure Foundations for Java Developers

Symbols and Keywords

How names and identifiers work in Clojure: symbols, keywords, and when to use each.

Symbols and keywords look similar at first, but they play very different roles.

  • A symbol is a name used by the evaluator and compiler. It resolves to a local binding (like a Java local variable) or a var (like a static field / method reference) in some namespace.
  • A keyword is a value typically used in data. It’s self-evaluating, commonly used as a map key, and it can be used as a function to look itself up in a map.

Java mental model: symbols are how you refer to code; keywords are how you label data.

Practical defaults

  • Prefer keywords for keys in maps that represent domain data: {:user/id 42 :user/name "Ada"}.
  • Prefer symbols when you’re talking about code: locals in let, function parameters, vars you def/defn, and namespaced references like clojure.string/join.

Tiny examples

1(def user {:user/id 42 :user/name "Ada"})
2
3(:user/id user)        ;; => 42   (keyword as a function)
4(get user :user/name)  ;; => "Ada"

When you see a plain token like user in code, it’s usually a symbol being resolved. When you see :user/id, it’s a keyword value being used to label and access data.

In this section

  • Understanding Symbols
    Learn how symbols name locals, vars, classes, and code forms in everyday Clojure.
  • Working with Keywords
    Use keywords to model map keys, statuses, and qualified domain labels without stringly typed noise.
  • Symbols vs Keywords
    Separate code names from data labels so Clojure forms become much easier to read and review.
Revised on Friday, April 24, 2026