You can get an Experience boost or penalty depending on level difference between you and the enemy, however, since version 5 of N Terraria, the minimum experience penalty you may get by killing low level monsters is 10%.

Events can either increase or decrease your exp gain.

Killing bosses without being hit doubles the exp gain.

Once your experience bar fills up you will level up, which will improve your stats.

Non-N Terraria 5 Mechanics

Combo System

Introduced in version 3.1.3 B, with attack experience enabled, every attack done by a character on a hostile mob adds to a player's combo counter. This counter is reset after a few seconds without landing an attack or whenever the player takes damage including damage taken from the environment like lava, falling, and thorns.

Increase in the attack experience are calculated using this formula: ExperiencePerDmg=1+(0.01*Combos). Such that 1000 combos would give 11xp for every point of damage done to an enemy.

Combos also improve experience gained from killing enemies, but more testing is needed to find out how it is applied.

Attack Experience

By default, attacks give additional base experience points, this can be configured in the settings tab. The experience is based on the damage done and the current number of combos.

World Level

The world level determines what level the NPCs are at and how much bonus experience characters will get. All NPCs will be the same level as the world is, and the xp bonus is 2* at world level 100.

Character Level Tables

Experience listed as how much needed to get from listed level to the next, so that 125 experience is needed to get from level 1 to level 2.