The invention relates to a device and method for forming a knot to elongated material (30). The device comprises a body (2, 4), a central cavity (13, 15) inside the body (2, 4), a material track (3, 5) along which the elongated material (30) is guided in the device, the material track (3, 5) comprising opening (32) extending along the material track (3, 5) and open to the central cavity (13, 15). The device further comprises one or more barrier elements (8; 33, 34) for blocking at least part of the opening (32) for preventing the elongated material from escaping from the material track also prevents collapsing/folding of the material (3, 5) to the central cavity (13, 15) via the opening (32).