Question and answer codes

Question and answer codes

What codes are

Every question, sub-question, and answer option in LimeSurvey has a short identifier — its code:

  • Question codes — one per question, such as Q001. LimeSurvey assigns these automatically; you can rename them.
  • Sub-question codes — one per row of a question with sub-questions (arrays, multiple short text…), such as SQ001, SQ002.
  • Answer option codes — one per answer option, such as A001.

You can ignore codes entirely for a simple survey. They matter the moment you use anything that refers to an answer: piping ({name}), conditions, validation equations, equation questions — and they become the column names when you export responses for analysis.

Showing the codes in the editor

By default the editor hides codes. There are two ways to turn them on:

  • Right-click a question in the Structure sidebar and choose Show/hide question codes. The same menu offers Copy question code — handy when writing an expression.
  • Or open the "..." menu in the top bar and under View, choose Question codes.

With codes shown, each question in the Structure sidebar gets a code badge next to its name (Q001, Q002…), and on the canvas each sub-question shows its code (SQ001, SQ002…) in a small box next to the row.

Changing a code

  • Question code — click the question, open the Question settings panel, and edit the Question code field (on the Advanced tab). This is also where you give questions meaningful names: renaming Q001 to age makes every expression that uses it readable — {age} instead of {Q001}.
  • Sub-question code — with codes shown, click the code box next to the sub-question on the canvas and type.

Codes must be unique within the survey and are kept short — letters and numbers. If you plan to reference a question in logic or text, rename its code before writing the expressions; expressions refer to codes by name, so renaming afterwards means updating every expression that uses the old one.

Where you meet codes again

  • Piping: Hello {firstname} shows the answer to the question coded firstname.
  • Conditions and validation: a sub-question is addressed as question code + underscore + sub-question code, e.g. Q001_SQ001; an answer option by its code, e.g. A001.
  • Exports: your response file's columns are named by these codes — one more reason to make them meaningful before fieldwork starts.

Related articles