We invert directly the redshift–luminosity distribution of observed long Swift gamma-ray bursts (GRBs) to obtain their rate and luminosity function. Our best-fitting rate is described by a broken power law that rises like for 0 < z < 3 and decreases like for z > 3. The local rate is ρ0≃ 1.3+0.6−0.7 (Gpc−3 yr−1). The luminosity function is well described by a broken power law with a break at L*≃ 1052.5±0.2 (erg s−1) and with indices α= 0.2+0.2−0.1 and β= 1.4+0.3−0.6. The recently detected GRB 090423, with z≈ 8, fits nicely into the model's prediction, verifying that we are allowed to extend our results to high redshifts. While the GRB rate may follow the star formation rate (SFR) for z < 3, the high-redshift slope is shallower than the steep decline in the SFR for 4 < z. However, we cannot rule out a GRB rate that follows one of the recent SFR models.