Sometimes I read a sentence containing the word canonical, but I cannot find appropriate meaning of the word.

For example, in this link:

Returns a canonical representation for the string object.

It's hard for me to find an appropriate definition from Google:

ca·non·i·cal Adjective /kəˈnänikəl/

  1. According to or ordered by canon law
    • the canonical rites of the Roman Church
  2. Included in the list of sacred books officially accepted as genuine
    • the canonical Gospels of the New Testament
  3. Accepted as being accurate and authoritative
    • the canonical method of comparative linguistics
  4. (of an artist or work) Belonging to the literary or artistic canon
    • canonical writers like Jane Austen
  5. According to recognized rules or scientific laws
    • canonical nucleotide sequences
  6. Of or relating to a general rule or standard formula
  7. Of or relating to a cathedral chapter or a member of it
  • 2
    This is really a programming question, and to be honest even the programmers aren't sure what their current jargon means. But here is the issue as asked on StackOverflow. I'm going to vote to close this one as not relevant to normal English as we understand it at ELU. Commented Jul 20, 2011 at 4:05
  • 6
    @FumbleFingers, this is definitively not a programming question. It is a question about a specific context, however I feel that OP has an interest to learn about the word itself and how it came to be used in specific context (in specific jargon). I would vote not to close if there was a button for that.
    – Unreason
    Commented Jul 20, 2011 at 9:55
  • 1
    @Unreason: Well I think OP's usage is highly specific to programming. Stacker, for example, has pretty much defined the meaning - pretty much OP's defn:6, except in this case there's no special reason to assume conformance to any particular standard - so long as all references are canonical in respect of the same standard, that's all that matters. But it's fully covered by Answers in the StackOverflow link I gave, and I don't see what ELU is likely to add to that. Commented Jul 20, 2011 at 15:03
  • 3
    @FumbleFingers, EL&U can explain connection to standard English; a lot of people learn English through specific, expert language and jargon so they know what a word means in their field, but can not connect it general language. The link you provided explains only the specific meaning and does not tie back to the usage in general sense.
    – Unreason
    Commented Jul 20, 2011 at 15:08
  • 2
    @Unreason: "a lot of people learn English through specific, expert language and jargon" +1 That is exactly what I want to say.
    – Lenik
    Commented Jul 28, 2011 at 3:42

7 Answers 7


When this word is used by programmers, it is a synonym for "authoritative," "standard," or "official." That's meaning number 3 in the definition you quote.

It implies that there is one best, most official, most standard way to represent the string object and this is it.

For example sometimes things can be represented using a relative link or an absolute link. Relative might be something like ../foo.txt meaning "The file foo.txt in the folder above this one" while absolute is something like \\www.example.com\fileserver\share\foo.txt which can only refer to one file on the Internet. One might say that the latter name is canonical.

  • 4
    On the side of precision I'd like to point out that canonical is not necessary the best way; it is only canonical: standardized and widely known/used/understood. (It might be the best, but it is not a defining characteristic; for example absolute path is not the best form for a path, but it is best to use it in scripts due to several reasons that became canon)
    – Unreason
    Commented Jul 20, 2011 at 11:00
  • 4
    When I (as a programmer) use it, I don't mean either "authoritative" or "official": I mean "in the most standard form", which usually has a precise definition.
    – Colin Fine
    Commented Jul 20, 2011 at 13:50
  • Good point; I will revise my answer. Commented Jul 20, 2011 at 13:55

In computing, the "canonical" form of something usually means something like "a standardised base form, to which any given variant resolves when you apply any relevant conversions". For example, you could have various paths "$NEILSDIR$\Directory", "$USERPATH$\Neil\Directory", but the canonical form of these might be "C:\Users\Neil\Directory".

Another type of conversion that the word commonly applies to is character encoding.

Unfortunately, I don't think the general dictionary entry you quote gives you so much of a clue in this case as to the technical use.


Of the dictionary meanings given, three of them are very similar:

3. Accepted as being accurate and authoritative
5. According to recognized rules or scientific laws
6. Of or relating to a general rule or standard formula

The first two of these imply reference to an authority or recognized rule, which is usually not the case for a programming usage like canonical representation. The last (definition 6) is the most appropriate: according to a general rule.

For example, strings might be considered equivalent whether in upper case or lower case. For a particular program, the designer might have a rule that all strings are to be stored in upper case. That means that upper case is the canonical representation.


This is an interesting word within and out of programming context. A nice mix of explanations from both perspectives can be found in good old jargon file - see canonical.

The usual or standard state or manner of something. This word has a somewhat more technical meaning in mathematics. Two formulas such as 9 + x and x + 9 are said to be equivalent because they mean the same thing, but the second one is in canonical form because it is written in the usual way, with the highest power of x first. Usually there are fixed rules you can use to decide whether something is in canonical form. The jargon meaning, a relaxation of the technical meaning, acquired its present loading in computer-science culture largely through its prominence in Alonzo Church's work in computation theory and mathematical logic (see Knights of the Lambda Calculus). Compare vanilla.

  • This is wonderful!!
    – 9dan
    Commented Jan 29, 2015 at 8:43

Regarding that particular usage, describing the function of Java's intern function is always a challenge, and the writer was no doubt casting about for some descriptive term to use.

All Java "Strings" are "canonical" in that there is only one form that they can be in, with only the values of the characters contained within distinguishing them.

However, at most one String with a given character value may be designated as the "interned" String, for reasons that have nothing to do with English. So "canonical" is a stretch, but it's the only word the writer could think of that sorta fit.

  • Nod a good choice of words on the author’s part, given how the two distinct strings "Jos\u00E9" and "Jose\u0301" are canonically equivalent.
    – tchrist
    Commented Dec 7, 2014 at 16:14
  • @tchrist - I assume that you mean that the two display identically? They would not compare identically, of course. And "canonical", even when limited to computing, has no "hard" meaning, but (in general, not specific to Java) basically means "standard" or "formal".
    – Hot Licks
    Commented Dec 7, 2014 at 20:02
  • No, I do not mean that, since display is immaterial. And yes, they will very most certainly compare the same if and only if you are comparing them correctly. One is in NFD, formed by canonical decomposition, while the other is in NFC, formed by canonical decomposition followed by canonical composition. Bits are immaterial; this is text, not binary, and as such, you must by definition equality-compare canonically equivalent forms. Please study how to correctly compare Unicode strings before it’s too late.
    – tchrist
    Commented Dec 7, 2014 at 20:13
  • @tchrist - Once again, it depends on the definition you choose for "canonical".
    – Hot Licks
    Commented Dec 7, 2014 at 20:20

From http://www.webopedia.com/TERM/C/canonical.html

(adj.) Authoritative or standard; conforming to an accepted rule or procedure. When referring to programming, canonical means conforming to well-established patterns or rules. The term is typically used to describe whether or not a programming interface follows the already established standard.

In Java string literals are stored in the source code depending on your encoding e.g. Latin-1, internaly UTF-8 is used. The canonical representation means that Unicode "\u000a" (6 bytes) will be transformed to the UTF-8 representation of a linefeed (1 byte).

I'm not sure whether canonical could be applied to variable expansion, for directories I would give another example: C:\users\admin\..\neil would be normalized to C:\users\neil

  • For the benefit of those who don't know, "..\" in a directory path means parent of the directory parsed to so far. So "admin\..\" just pointlessly goes down to "admin\" and back up again, meaning that bit can be removed without making any difference. Like you, I'd call that normalisation rather than canonicalisation. (Yeah yeah, I know you'd have z's in both, but you know what I mean! :) Commented Jul 20, 2011 at 15:10
  • 1
    ...in short, canonicalisation is just an unnecessary techie jargon alternative to standardisation. Commented Jul 20, 2011 at 15:13
  • But you fail to explain the meaning of "canonical" in the referenced article. Based on your explanation every Java String object would be "canonical", and it's use in the article would be redundant and meaningless.
    – Hot Licks
    Commented Dec 7, 2014 at 20:05


As already established, the meaning of certain words vary (interpretation within the scope of an event) when applied to a certain environment. Fortunately, "Canonical" has been inquired only in the technical aspect. Thus the clarification keeping in mind this highly advanced era of 1s and 0s.

"Most relevant and accurate based on a set of predefined rules within a system"

This is a system/environment depenent explanation. The canonical output of System A may or may not mirror the result of System B; it will however if the set of rules under which the result is evaluated are identical.

Not the answer you're looking for? Browse other questions tagged or ask your own question.