Apparatus for compact embedded-wire welding of electrical wires, comprising: a set of pre-welding electrodes adapted to shape a cross-section of a first segment of a first wire with a pre-welding shape which includes a reentrance for accommodating a second segment of a second wire to be welded to the first wire , the set of pre-welding electrodes comprises: a shape-forming electrode having a contact face with a shape-forming structure adapted to transfer said pre-welding shape with said reentrance to the first segment upon compression of the first segment against said contact face ; wherein the shape-forming structure at the contact face of the shape-forming electrode includes a groove with a protrusion at an intermediate position of the groove , thereby forming a W-shaped cavity adapted to form parallel ridges on each side of the reentrance of the pre-welding shape, and wherein said protrusion has a height and width adapted to form said reentrance on the cross-section of the first segment for accommodating the second segment of the second wire and the apparatus further comprising a set of welding electrodes adapted to apply a welding potential difference between a first position (P1) and a second position (P2) along a longitudinal direction of the first segment for welding the first segment to the second segment arranged in the reentrance of the pre-welding shape. a set of pre-welding electrodes adapted to shape a cross-section of a first segment of a first wire with a pre-welding shape which includes a reentrance for accommodating a second segment of a second wire to be welded to the first wire , the set of pre-welding electrodes comprises: a shape-forming electrode having a contact face with a shape-forming structure adapted to transfer said pre-welding shape with said reentrance to the first segment upon compression of the first segment against said contact face ; wherein the shape-forming structure at the contact face of the shape-forming electrode includes a groove with a protrusion at an intermediate position of the groove , thereby forming a W-shaped cavity adapted to form parallel ridges on each side of the reentrance of the pre-welding shape, and wherein said protrusion has a height and width adapted to form said reentrance on the cross-section of the first segment for accommodating the second segment of the second wire and the apparatus further comprising a set of welding electrodes adapted to apply a welding potential difference between a first position (P1) and a second position (P2) along a longitudinal direction of the first segment for welding the first segment to the second segment arranged in the reentrance of the pre-welding shape. a shape-forming electrode having a contact face with a shape-forming structure adapted to transfer said pre-welding shape with said reentrance to the first segment upon compression of the first segment against said contact face ; wherein the shape-forming structure at the contact face of the shape-forming electrode includes a groove with a protrusion at an intermediate position of the groove , thereby forming a W-shaped cavity adapted to form parallel ridges on each side of the reentrance of the pre-welding shape, and wherein said protrusion has a height and width adapted to form said reentrance on the cross-section of the first segment for accommodating the second segment of the second wire and the apparatus further comprising a set of welding electrodes adapted to apply a welding potential difference between a first position (P1) and a second position (P2) along a longitudinal direction of the first segment for welding the first segment to the second segment arranged in the reentrance of the pre-welding shape. <EOS>