From the Super Mario Wiki
Sparks are orb-shaped creatures who continually emit pulses and flashes of electricity. They are mostly found crawling around walls and ceilings and moving across wires.
Donkey Kong Jr.
They first appear in Donkey Kong Jr.. Sparks are generated by Mario in order to destroy Donkey Kong Jr., preventing him from saving his father. They appear only in Stage 3. Yellow Sparks circle platforms but blue faceless ones can travel to other platforms through wires.
In Donkey Kong on the Game Boy, Sparks always appear on ropes. If Mario touches a spark, he gets killed. Sparks may appear and disappear from a rope in certain time intervals. They can not be destroyed.
Super Mario Bros. 2
Sparks also appear in Super Mario Bros. 2 as uncommon enemies, usually encountered underground or in buildings, circling platforms though some can hover in the air. Sparks can be defeated by throwing an object at them. Sparks can't be jumped on and can hurt the player's character by simply touching them.
Sparks changed slightly in Super Mario Advance. If the player hit one, they would be knocked back and the screen would flash.
Super Mario Bros. Super Show!
A Spark makes only one appearance on The Super Mario Bros. Super Show!, in the episode "On Her Majesty's Sewer Service". Having been dumped into the Tunnel of Doom, Mario and Luigi, while running from a Goomba, encounter a Spark that is quickly approaching. Mario and Luigi manage to avoid this Spark and the Goomba by creating a grappling hook out of a super spy hose nozzle and mini plunger; apparently unable to stop moving, the Spark and Goomba subsequently crash into one another, causing an explosion. In this appearance, the Spark featured does not radiate any electricity at all.
Nintendo Comics System
Sparks are featured quite prominently in issues of Nintendo Comics System, appearing in such stories as "The Legend", "Bedtime for Drain-Head" and "A Mouser in the Houser". Unlike other versions of Sparks, the comic book versions of Sparks are shown to be fully capable of speaking.
Mario vs. Donkey Kong
The blue faceless variety appears in Mario vs. Donkey Kong as it travels through wires.
Mario vs. Donkey Kong 2: March of the Minis
Though absent from a game for some time, the yellow Sparks have recently made a comeback in the game Mario vs. Donkey Kong 2: March of the Minis, in levels taking place in the Magnet Mania area. In Japan, they are called Magnet Sparkies (マグネットスパーキー).
Mario vs. Donkey Kong: Mini-Land Mayhem!
The yellow ones reappear once more in Mario vs. Donkey Kong: Mini-Land Mayhem!. They walk around the magnet, with a faster movement than the minis.
Super Paper Mario
Names in other languages