A metaquine is a program which is not a quine, but whose output, when run as a program in the same language, is a quine.

The goal of this challenge is to write a metaquine. This is , so shortest code wins, with earliest answer used as a tiebreaker. Note that only full programs are acceptable, due to the definition of a quine.

Rules for Quines

Only true quines are accepted. That is, you need to print the entire source code verbatim to STDOUT, without:

  • reading your source code, directly or indirectly.
  • relying on a REPL environment which just simply evaluates and prints every expression you feed it.
  • relying on language features which just print out the source in certain cases.
  • using error messages or STDERR to write all or part of the quine. (You may write things to STDERR or produce warnings/non-fatal errors as long as STDOUT is a valid quine and the error messages are not part of it.)
  • the source code consisting purely of literals (whether they be string literals, numeric literals, etc.) and/or NOPs.

Any non-suppressible output (such as copyright notices, startup/shutdown messages, or a trailing line feed) may be ignored in the output for the sake of the validity of the quine.


Ignoring the rule which forbids literal-only programs and built-in quining, this would be a metaquine in Seriously:


The program consists of the single string literal "Q", which is implicitly printed at output. When the output (Q) is run, it is a quine (Q is the built-in quine function).

  • 2
    \$\begingroup\$ Does the literals/comments/NOPs rule apply to the output (i.e. the real quine) of the metaquote as well? Otherwise ex. T is an easy 1-byte Pyth answer. \$\endgroup\$ – Doorknob Feb 12 '16 at 18:23
  • \$\begingroup\$ @Doorknob Yes, I'll clarify. \$\endgroup\$ – user45941 Feb 12 '16 at 18:25
  • 8
    \$\begingroup\$ I don't really see where's the difficult point of this challenge. Isn't the strategy "print the string which contains the shortest known quine" pretty much guaranteed to win for each language? \$\endgroup\$ – Fatalize Feb 12 '16 at 18:30
  • 1
    \$\begingroup\$ @Fatalize Well I guess the interesting question is, can that be done in the same amount or fewer bytes than the quine itself. \$\endgroup\$ – Martin Ender Feb 12 '16 at 18:53
  • 3
    \$\begingroup\$ @Fatalize Isn't it also possible that you could write a short metaquine that prints a long but valid quine? \$\endgroup\$ – Rhyzomatic Feb 12 '16 at 19:25

20 Answers 20


CJam, 6 bytes




which is the shortest proper quine in CJam.

Test it here.


Both programs work exactly the same, since the linefeed inside the proper quine is a no-op and only included because it's more expensive to remove it from the output. How the programs work:

"_p"  e# Push this string.
_     e# Duplicate it.
p     e# Print a string representation of the top of the stack (i.e. the string with
      e# quotes) followed by a linefeed.
      e# The other copy is then printed automatically at the end of the program, without
      e# stringifying it.

Side Note

The same works in GolfScript as


which prints


with a trailing linefeed, which in turn is one of the shortest known quines.


Pyth, 12 11 10 9 bytes

Knocked off one more byte thanks to @Pietu1998.

jN B".[9N

This prints


which is a quine in Pyth. You can try it out here.

  • \$\begingroup\$ Is the output a new record for the shortest Pyth quine? I don't believe I've ever seen it before. \$\endgroup\$ – ETHproductions Feb 12 '16 at 21:08
  • \$\begingroup\$ I couldn't find it anywhere else. I came up with it trying to get a metaquine. \$\endgroup\$ – Rhyzomatic Feb 12 '16 at 21:11
  • 1
    \$\begingroup\$ Perhaps you should post it as an answer to the original quine challenge :) \$\endgroup\$ – ETHproductions Feb 13 '16 at 1:08
  • 2
    \$\begingroup\$ You can get this down to 9 by using jN B".[9N or .[9N"jN B. (jN B"jN B is another true quine at 9: bifurcate identity function and join by ".) \$\endgroup\$ – PurkkaKoodari Feb 13 '16 at 1:36
  • \$\begingroup\$ @Pietu1998 Thanks! I knew there must be a way to get it to 9. Are there any quines in Pyth that are shorter than 9 bytes? \$\endgroup\$ – Rhyzomatic Feb 13 '16 at 5:50

Fission, 6 bytes




Which is the shortest Fission quine. This works because cyclic shifts of the program leave its output completely unaffected.

Try it online!


Javascript ES6, 21 bytes



  • 3
    \$\begingroup\$ Happy 3k!!!!!!! \$\endgroup\$ – Conor O'Brien Feb 13 '16 at 1:00
  • 2
    \$\begingroup\$ @ConorO'Brien Wow, much rep. 3k factorial is already more than Jon Skeet... \$\endgroup\$ – NoOneIsHere Dec 10 '16 at 7:06

Python 2, 29 bytes

_="_=%r;print _%%_";print _%_

Turns out the well-known short python quine is easily turned into a metaquine :)

And, since we don't have to worry about matching the trailing newline, the metaquine is actually shorter!

  • \$\begingroup\$ beat me to it, again :( I thought of a wrapper, but yours is better \$\endgroup\$ – Erik the Outgolfer Sep 14 '16 at 12:52

Japt, 15 13 bytes

Q+"+Q ³s7J" ²

Test it online!

This program outputs

"+Q ³s7J"+Q ³s7J

which is the shortest known quine in Japt.

How it works

Q+"..." // Take a quotation mark plus this string.  "+Q ³s7J
²       // Repeat it twice.                         "+Q ³s7J"+Q ³s7J
        // Implicit output

Non-competing version, 11 bytes

Q+"+Q ²é" ²

I've just added é, a "rotate" command. So

"+Q ²é"+Q ²é

is now a valid quine.


Ruby, 25 23

puts"puts <<2*2,2

Generates the classic Ruby HEREdoc quine

puts <<2*2,2
puts <<2*2,2

Old solution


Generates itself except with the single quotes replaced with double quotes.


JavaScript, 50 bytes


Based on the shortest non-source-reading JS quine known to man, but a good 8 bytes shorter. Prints


which is a quine.


Fish (><>), 17 bytes

This works using the classic fish quine "r00g!;oooooooo| but adds a { which shifts the entire stack to the left so that the original program isn't a quine, but it's output, when run, is.




which is a fish quine!


Jelly, 3 bytes (non-competing)

Unfortunately, the required atoms are roughly 2 weeks younger than the challenge.



Try it online!

How it works

”Ṙv  Main link. No arguments.

”Ṙ   Set the left argument and the return value to the character 'Ṙ'.
  v  Dyadic eval; evaluate the return value with the left argument as argument.
     Executing the atom Ṙ on the argument 'Ṙ' prints a string representation of
     the character, i.e., the string "”Ṙ".
     Finally, v returns its unaltered argument, which is printed implicitly.



Try it online!

How it works

”ṘṘ  Main link. No arguments.

”Ṙ   Set the left argument and the return value to the character 'Ṙ'.
  Ṙ  Print a string representation of the character, i.e., the string "”Ṙ".
     (implicit) Print the unaltered return value.

Since the second prints the first two characters (”Ṙ), this is a proper quine by our definition.


Octopen-Baru, 22 bytes

** Non competing answer


Ruby output

puts [35211].pack(' U')

Which outputs . Which is a quine in Octopen-Baru!


7, 2 bytes, language postdates challenge

The program is two bytes long, and can be interpreted in several ways; as a hex dump:

00000000: 4ff4                                     O.

as codepage 437:


or, most readably, in octal (which 7 natively uses):


Try it online!

The workings of this are very simple: it's the standard 7 quine with a no-op stack element inserted between the two halves, to make it different (in this context, 7 separates stack elements). (I could also have inserted it at the start, 723723. I couldn't have interpreted it at the end because trailing 7s are like trailing whitespace, and ignored in the packed encoding, thus it wouldn't be any different from the output program.)

Incidentally, this program is a in hexadecimal, but that's mostly just coincidence.


Underload, 11 bytes


Pretty simple. It prints out (:aSS):aSS, which is the standard Underload quine.


Brachylog, 12 bytes


Try it online!

One of 132 same-length metaquine variations on the quine I translated from Fatalize's Brachylog v1 (non-cheating) quine. I actually wrote a (non-golfed, and overall silly) program to print all of them out:

{[[";?","gj","jḍ"],"₁₃₅₇"]j∋ᵐ{ḍ≠&};"\"~~k~ww~w\"~ww~w~n"}ᶠ{lw" metaquines generated:

Try it online!

There are two parts of the original quine which could be replaced inconsequentially: ;? can be changed to gj or jḍ, and can be changed to , , or . If we keep or change them outside the string literal in one way and inside the string literal in a different way, then the output won't match the source, because whichever variants were present within the string literal will be printed both inside and outside it, resulting in a quine which was not the initial program run.

;?, gj, and jḍ are interchangeable because all three pair the string literal with itself: due to the layout of the program, the input variable ? is unified with the string, so ;? pairs the string with itself; regardless of the layout, gj wraps the string in a list which is then concatenated to itself; likewise jḍ concatenates the string to itself then splits it in half.

The odd-numbered w subscripts are interchangeable because, although originally w could only take 0 or 1, with 0 printing the input to w and 1 printing the first element formatted with the second, the subscript inventory for w has grown into something that externally functions as a bitfield: the low bit of the subscript encodes whether it's direct or formatted, the middle bit encodes whether the output variable from w is unconstrained or set to the input, and the high bit encodes whether the printing is done immediately or if it's delayed until the end of the program so it can be subject to backtracking. (Those subscripts were my first and so far largest contribution to Brachylog.) Since the quine and metaquine don't use the output variable and don't backtrack, all four odd subscripts are equivalent.


Befunge-93, 22 bytes


I just took the standard quine, put it in quotes, reversed it (so it is loaded on the stack correctly), and then added a stack-print at the end.

It's 8 characters added to the normal quine, so it's very possible there's a better solution.

  • \$\begingroup\$ Couldn't you just take the standard quine and add a newline? The newline will disappear at the parsing stage, leaving you with just the standard quine (which will print itself). \$\endgroup\$ – user62131 Dec 31 '16 at 22:35

Turtlèd, 52 bytes (noncompeting)

1 less than original quine

@##'@r,r,r-{ +.r_}r{ +.r_}"#'@r,r,r-{ +.r_}r{ +.r_}"

Works in the same way, except that it does not have a character at the end, when run, it will have a character at the end, that does not effect output, because it writes # on to a #. Note the output is slightly different to the quine I have made for the quine challenge, but works the same: " writes #, which is its own last character, like the quine I made. Check out the explanation there.


Lua, 45 bytes

Quine code not mine.


will result in


which is a quine. Glad the ; is optional in Lua.


Pushy, 7 bytes

Non-competing as the language postdates the challenge.

This is the standard quine, but with newlines removed. Newlines mean nothing in Pushy, but are the print operator's standard separator, and therefore needed for a true quine.

95 34_"

Try it online! This outputs:

95 34

Which is the shortest Pushy quine - an explanation on how it works can be found here.

Alternatively, H5-34_" works for the same byte count.


Foam, 14 bytes

[. .'|: ~|]: ~

This prints the second Foam quine that can be found here. This is actually shorter because . will always put a space between each element, but the bar in the third token allows me to omit the space before it.

  • \$\begingroup\$ I've removed the non-competing bit because newer languages are not automatically non-competing as per site policy. \$\endgroup\$ – user45941 Jul 9 '17 at 0:21

Husk, 6 bytes


Try it online!

Prints the standard Husk quine S+s"S+s".

 "S+s¨    The string S+s"
D         concatenated with itself.

The quine explained:

   "S+s"    The string S+s
 +          concatenated with
S           itself passed through
  s         the function which returns its string representation.