.clj

What is a .clj file?

Clojure Source File · Code and data · Rich Hickey · 2007

A .clj file is Clojure source code, a modern Lisp dialect that runs on the Java Virtual Machine. It emphasises functional programming and immutable data, and is valued for concise, robust backends and data processing.

Category
Code and data
Type
Plain text
Is a .clj file safe to open? Caution. A .clj file is program source that runs on the JVM. Review unfamiliar code before running it.

What is a .clj file used for?

Clojure is a Lisp, so code is written as parenthesised expressions and data and code share the same structure. It runs on the JVM (and ClojureScript targets JavaScript), giving access to the Java ecosystem.

The files are plain text; editors with structural editing (Calva for VS Code, Cursive for IntelliJ) make the parentheses easy to manage.

How to open a .clj file

The .clj format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list. For a step-by-step walkthrough, see how to open a .clj file.

Windows

  • VS Code (Calva)
  • IntelliJ IDEA (Cursive)
  • any text editor

macOS

  • VS Code (Calva)
  • IntelliJ IDEA (Cursive)
  • any text editor

Linux

  • VS Code (Calva)
  • Emacs (CIDER)
  • any text editor

.clj file signature (magic bytes)

Programs recognise a .clj file by the bytes at the start of the file, not by its name. These are the signatures for Clojure.

Hex signatureOffsetNote
(no fixed signature)0plain text; no fixed magic bytes

See the full magic-numbers reference for every format.

Frequently asked questions

What is a .clj file?

A .clj file is Clojure source code, a modern Lisp dialect that runs on the Java Virtual Machine. It emphasises functional programming and immutable data, and is valued for concise, robust backends and data processing.

How do I run a .clj file?

Use the Clojure CLI (clojure -M file.clj) or a REPL, or run it inside a project with Leiningen or deps.edn tooling.

Is Clojure a Lisp?

Yes. Clojure is a modern Lisp dialect on the JVM, using S-expressions and treating code as data, with a strong focus on immutability.

What is the difference between .clj and .cljs?

A .clj file targets the JVM; a .cljs file is ClojureScript, which compiles to JavaScript for the browser. The language is largely shared.

Related formats

Sources

Details on this page were checked against authoritative references: