.clj File Extension

Learn what a .clj file contains, how to open and run Clojure source, how Poly supports it, and when to use .cljc or .cljs instead.

File extension details for .clj

Full Support
File typeClojure source code
MIME type
EncodingPlain text, commonly UTF-8
Operating systemsWindows, macOS, Linux
Opens withVisual Studio Code with Calva, IntelliJ IDEA with Cursive, Emacs with CIDER, Vim or Neovim
Poly supportYes. Poly recognizes .clj as readable Clojure source code.
Indexed by PolyYes. Poly indexes readable source for exact and semantic search.
Preview in PolyYes. Clojure source opens in Poly's code editor with syntax highlighting.
Poly agentYes. The Poly agent can read and reason about the source text.

What kind of file is a .clj?

A .clj file contains Clojure source code, usually for the Java Virtual Machine. It is readable text rather than a compiled program. The Clojure Reader turns its expressions into Clojure data, then the compiler can produce JVM bytecode.1

Most .clj files define one namespace with an ns form. Namespace and path normally correspond: com.some-example.my-app maps to com/some_example/my_app.clj.2 There are no fixed magic bytes, so software relies on the suffix, supplied media type, or source syntax.

There is no Clojure-specific type in the IANA media-type registry.3 Some software uses the unregistered text/x-clojure; Poly classifies .clj as readable text/plain. The encoding is commonly UTF-8, but the suffix does not declare it.

Renaming a .cljs, .cljc, or Java file to .clj does not translate its code. It only changes the filename and may cause tools to apply the wrong language rules.

How do I open a .clj on my computer?

Any text editor can open .clj. For interactive development, try Visual Studio Code with Calva, IntelliJ IDEA with Cursive, Emacs with CIDER, or Vim or Neovim with a Clojure plugin. Clojure's editor guide recommends structural editing and evaluation through a connected REPL.4

Install Java and the Clojure CLI when you need to evaluate the code. In a project with its dependencies configured, a namespace with a -main function can be run with:

clj -M -m my-app.core

You can also call a function with clj -X namespace/function.5 Follow the project's deps.edn and run instructions. Opening source as text does not run it. Evaluation can execute arbitrary code and load dependencies, so isolate untrusted projects.

Poly support for .clj

Poly opens .clj files in a read-only viewer with Clojure syntax highlighting, word wrap, and in-file search. It indexes readable source for exact and semantic search, so you can search by symbol or purpose.

The Poly agent can summarize a namespace, explain a form, or help trace likely behavior. Poly does not evaluate files, resolve dependencies, expand macros, or reproduce runtime state. Keep related source, deps.edn, tests, and documentation together when context matters.

History of .clj

Rich Hickey created Clojure after a two-year sabbatical and presented it publicly at LispNYC in late 2007.6 .clj became its standard JVM-source suffix.

Libraries can exist as compiled .class files, platform-specific .clj source, or portable .cljc source. When .clj and .cljc versions coexist, Clojure prefers .clj.7

Working with .clj and alternatives

Choose the suffix that matches what the file is meant to contain:

ExtensionTypical role
.cljClojure source for the JVM
.cljcPortable source shared across Clojure platforms
.cljsClojureScript source, commonly compiled to JavaScript
.ednData written in Extensible Data Notation, not application source
.classCompiled JVM bytecode

Reader conditionals such as #?(:clj ... :cljs ...) belong in .cljc when small platform-specific differences must share one source file. The feature arrived in Clojure 1.7; the official guide recommends separate .clj and .cljs files when code is largely platform-specific.8

Keep .clj in version control. Generated .class files and JARs are build outputs, not substitutes for editable source or convenient code review.

Footnotes

  1. Clojure. Learn Clojure: Syntax.
  2. Clojure. Learn Clojure: Namespaces.
  3. Internet Assigned Numbers Authority. Media Types Registry.
  4. Clojure. Editors.
  5. Clojure. Deps and CLI Guide.
  6. Clojure. Clojure Governance and How It Got That Way.
  7. Clojure. Using Libs.
  8. Clojure. Reader Conditionals Guide.
© Poly Corp. 2026