structural:reformatting, structural:scholar_edition
In aquaria

Like most species in the carp family, goldfish produce a large amount of waste both in their feces and through their gills, releasing harmful chemicals into the water. Buildup of this waste to toxic levels can occur in a relatively short period of time, and can easily cause a goldfish's death. For common and comet varieties, each goldfish should have about 20 US gallons (76 L; 17 imp gal) of water. Smaller fantail goldfish should have about 10 US gallons (38 L; 8.3 imp gal) per goldfish. The water surface area determines how much oxygen diffuses and dissolves into the water. A general rule is have 1 square foot (0.093 m). Active aeration by way of a water pump, filter or fountain effectively increases the surface area agitation.

The goldfish is classified as a coldwater fish, and can live in unheated aquaria at a temperature comfortable for humans. However, rapid changes in temperature, for example in an office building in winter when the heat is turned off at night, can kill them, especially if the tank is small. Care must also be taken when adding water, as the new water may be of a different temperature. Temperatures under about 10 °C (50 °F) are dangerous to fancy varieties, though commons and comets can survive slightly lower temperatures. Extremely high temperatures (over 30 °C (86 °F)) can also harm goldfish. However, higher temperatures may help fight protozoan infestations by accelerating the parasite 's life cycle—thus eliminating it more quickly. The optimum temperature for goldfish is between 20 and 22 °C (68 and 72 °F).

Like all fish, goldfish do not like to be petted. In fact, touching a goldfish can endanger its health, because it can cause the protective slime coat to be damaged or removed, exposing the fish's skin to infection from bacteria or water-borne parasites. However, goldfish respond to people by surfacing at feeding time, and can be trained or acclimated to taking pellets or flakes from human fingers. The reputation of goldfish dying quickly is often due to poor care. The lifespan of goldfish in captivity can extend beyond 10 years.

If left in the dark for a period of time, goldfish gradually change color until they are almost gray. Goldfish produce pigment in response to light, similarly to how human skin becomes tanned in the sun. Fish have cells called chromatophores that produce pigments that reflect light and give the fish coloration. The color of a goldfish is determined by their diet, water quality, and exposure to light, along with age and health.

Because goldfish eat live plants, their presence in a planted aquarium can be problematic. Only a few aquarium plant species, such as Cryptocoryne and Anubias, can survive around goldfish, but they require special attention so that they are not uprooted.