Petroleum coke, abbreviated coke or petcoke, is a final carbon-rich solid material that derives from oil refining, and is one type of the group of fuels referred to as cokes. Petcoke is the coke that, in particular, derives from a final crackingprocess—a thermo-based chemical engineering process that splits long chain hydrocarbons of petroleum into shorter chains—that takes place in units termed coker units. (Other types of coke are derived from coal.) Stated succinctly, coke is the "carbonization product of high-boiling hydrocarbon fractions obtained in petroleum processing (heavy residues)." Petcoke is also produced in the production of synthetic crude oil (syncrude) from bitumen extracted from Canada’s oil sands and from Venezuela's Orinoco oil sands.

In petroleum coker units, residual oils from other distillation processes used in petroleum refining are treated at a high temperature and pressure leaving the petcoke after driving off gases and volatiles, and separating off remaining light and heavy oils. These processes are termed "coking processes", and most typically employ chemical engineering plant operations for the specific process of delayed coking.

This coke can either be fuel grade (high in sulfur and metals) or anode grade (low in sulfur and metals). The raw coke directly out of the coker is often referred to as green coke. In this context, "green" means unprocessed. The further processing of green coke by calcining in a rotary kiln removes residual volatile hydrocarbons from the coke. The calcined petroleum coke can be further processed in an anode baking oven to produce anode coke of the desired shape and physical properties. The anodes are mainly used in the aluminium and steel industry.

Petcoke is over 90% carbon and emits 5% to 10% more carbon dioxide (CO2) than coal on a per-unit-of-energy basis when it is burned. As petcoke has a higher energy content, petcoke emits between 30 and 80 percent more CO2 than coal per unit of weight. The difference between coal and coke in CO2 production per unit of energy produced depends upon the moisture in the coal, which increases the CO2 per unit of energy – heat of combustion) and on the volatile hydrocarbons in coal and coke, which decrease the CO2 per unit of energy. 

There are at least four basic types of petroleum coke, namely, needle coke, honeycomb coke, sponge coke and shot coke. Different types of petroleum coke have different microstructures due to differences in operating variables and nature of feedstock. Significant differences are also to be observed in the properties of the different types of coke, particularly ash and volatile matter contents.

Needle coke, also called acicular coke, is a highly crystalline petroleum coke used in the production of electrodes for the steel and aluminium industries and is particularly valuable because the electrodes must be replaced regularly. Needle coke is produced exclusively from either FCC decant oil or coal tar pitch.

Honeycomb coke is an intermediate coke, with ellipsoidal pores that are uniformly distributed. Compared to needle coke, honeycomb coke has a lower coefficient of thermal expansion and a lower electrical conductivity. 

Fuel-grade coke is classified as either sponge coke or shot coke morphology. While oil refiners have been producing coke for over 100 years, the mechanisms that cause sponge coke or shot coke to form are not well understood and cannot be accurately predicted. In general, lower temperatures and higher pressures promote sponge coke formation. Additionally, the amount of heptane insolubles present and the fraction of light components in the coker feed contribute.

While its high heat and low ash content make it a decent fuel for power generation in coal-fired boilers, petroleum coke is high in sulfur and low in volatile content, and this poses environmental (and technical) problems with its combustion. Its gross calorific value (HHV) is nearly 8000 Kcal/kg which is twice the value of average coal used in electricity generation. A common choice of sulfur recovering unit for burning petroleum coke is the SNOX Flue gas desulfurisation technology, which is based on the well-known WSA Process. Fluidized bed combustion is commonly used to burn petroleum coke. Gasification is increasingly used with this feedstock (often using gasifiers placed in the refineries themselves). 

Calcined petroleum coke (CPC) is the product from calcining petroleum coke. This coke is the product of the coker unit in a crude oil refinery. The calcined petroleum coke is used to make anodes for the aluminium, steel and titanium smelting industry. The green coke must have sufficiently low metal content to be used as anode material. Green coke with this low metal content is called anode-grade coke. When green coke has excessive metal content, it is not calcined and is used as fuel-grade coke in furnaces.